name: Planning with Files description: A comprehensive context management system for AI agents. Enforces externalizing memory to disk to prevent hallucinations and maintain long-term coherence.
Planning with Files (v2.2.0)
The Core Pattern:
Context Window = RAM(Volatile, Limited)Filesystem = Disk(Persistent, Unlimited)
Rule: Anything important MUST be written to disk immediately.
1. Critical Rules (Non-Negotiable)
1.1 Create Plan First
Never start a complex task (coding, research, refactoring) without creating or updating task_plan.md. This is your anchor.
1.2 The 2-Action Rule
"After every 2 view/browser/search operations, IMMEDIATELY save key findings to findings.md."
- Prevents "context window washouts" where new tokens push out old insights.
- If you read a file and find a bug, log it in
findings.mdbefore trying to fix it.
1.3 Read Before Decide
Before making a major decision (architecture change, deletion, new library), read the plan file.
- This refreshes your "Attention Window" with the original goals and constraints.
1.4 Update After Act
After completing a phase or a significant step:
- Mark the item as
[x]intask_plan.mdorprogress.md. - Log any errors encountered in
task_plan.md(Errors Section). - Note new files created.
1.5 The 3-Strike Error Protocol
If an action fails (e.g., test failure, API error, file not found):
- Attempt 1: Diagnose & Fix: Read error, identify root cause, apply fix.
- Attempt 2: Alternative Approach: If the exact same error happens, STOP. Do not try the same thing again. Use a different tool, library, or method.
- Attempt 3: Broader Rethink: Question your assumptions. Is the file path wrong? Is the logic flawed?
- AFTER 3 FAILURES: Escalate to User. Stop spinning your wheels.
2. File Goals
task_plan.md (The Strategy)
- Purpose: Defines what we are doing and how.
- Contains: Objectives, Step-by-step implementation plan, Current Status, Error Log.
- Update Frequency: At the start of a task, and after every major phase completion.
findings.md (The Memory)
- Purpose: Stores raw information, code snippets, documentation, and "aha!" moments.
- Contains: Relevant file content summaries, API references, decisions made, bug causes.
- Update Frequency: High. Every 2-3 tool calls during research/debugging.
progress.md (The Journal)
- Purpose: A chronological log of actions taken (optional if using
task.mdheavily/Agentic Mode). - Contains: Timestamps, specific commands run, test results.
3. Workflow Implementation
Phase 1: Initialization / Planning
- Check Context: Run
ls -Rorlist_dirto see if planning files exist. - Create/Read:
- Task Plan: Create
task_plan.mdusingtemplates/task_plan.mdas a guide. - Findings: Create
findings.mdusingtemplates/findings.mdfor research notes. - Note: You can use
read_file .agent/skills/planning-with-files/templates/task_plan.mdto see the structure.
- Task Plan: Create
Phase 2: Execution (The Loop)
- Read code/docs.
- Write findings to
findings.md(2-Action Rule). - Update
task_plan.mdif the plan changes based on findings. - Act (Write code, run command).
- Verify result.
- Log outcome to
progress.mdortask_plan.md.
4. When to Use
- USE FOR: Multi-step tasks, Debugging complex bugs, Feature implementation, Refactoring.
- SKIP FOR: Trivial one-shot questions (e.g., "What time is it?", "Fix this typo on line 10").
5. Anti-Patterns (What NOT to do)
- Storing everything in RAM: Relying on your context window to remember what you read 10 turns ago.
- "I'll remember that": You won't. Write it down.
- Looping on Errors: Retrying the same failing command 5 times hoping it works. (Use 3-Strike Protocol).