|
| 1 | +# Task Scope Adherence Pattern |
| 2 | + |
| 3 | +When given a specific technical task, implement ONLY what is explicitly requested. Do not add "helpful" extras, documentation, or related improvements unless specifically asked. |
| 4 | + |
| 5 | +## The Problem |
| 6 | + |
| 7 | +Agents often interpret tasks broadly and add related work they think would be helpful: |
| 8 | +- Task: "Remove the wait-for command" → Agent also creates 3 new documentation files |
| 9 | +- Task: "Fix the redirect" → Agent also refactors related code and adds tests |
| 10 | +- Task: "Update the config" → Agent also adds validation and error handling |
| 11 | + |
| 12 | +While well-intentioned, this scope creep can: |
| 13 | +- Introduce unintended changes that break existing functionality |
| 14 | +- Make code review more difficult by mixing requested changes with unrequested additions |
| 15 | +- Violate the principle of least change in production systems |
| 16 | +- Create maintenance burden for code the user didn't ask for |
| 17 | + |
| 18 | +## The Solution: Strict Scope Adherence |
| 19 | + |
| 20 | +### 1. Parse the Task Precisely |
| 21 | + |
| 22 | +Identify the exact scope from the task description: |
| 23 | +- "Remove the wait-for command" = delete wait-for implementation and references |
| 24 | +- "Add a redirect" = add one specific redirect rule |
| 25 | +- "Fix the test" = make the failing test pass |
| 26 | + |
| 27 | +### 2. Implement Only What's Requested |
| 28 | + |
| 29 | +**DO:** |
| 30 | +- Remove the specific command/feature mentioned |
| 31 | +- Update direct references to use the replacement |
| 32 | +- Fix compilation errors caused by the removal |
| 33 | +- Update usage examples that directly reference the removed feature |
| 34 | + |
| 35 | +**DON'T:** |
| 36 | +- Add new documentation files unless specifically requested |
| 37 | +- Refactor related code "while you're at it" |
| 38 | +- Add validation, error handling, or tests unless they're breaking |
| 39 | +- Create helper utilities or abstractions |
| 40 | +- Update tangentially related files |
| 41 | + |
| 42 | +### 3. Resist the Urge to "Improve" |
| 43 | + |
| 44 | +Common scope creep patterns to avoid: |
| 45 | + |
| 46 | +```typescript |
| 47 | +// Task: Remove deprecated function |
| 48 | +// WRONG - adding documentation |
| 49 | +const changes = [ |
| 50 | + 'Remove oldFunction()', |
| 51 | + 'Update all references', |
| 52 | + 'Add migration guide', // ❌ Not requested |
| 53 | + 'Create best practices doc', // ❌ Not requested |
| 54 | + 'Add usage examples' // ❌ Not requested |
| 55 | +] |
| 56 | + |
| 57 | +// CORRECT - minimal scope |
| 58 | +const changes = [ |
| 59 | + 'Remove oldFunction()', |
| 60 | + 'Update direct references to use newFunction()' |
| 61 | +] |
| 62 | +``` |
| 63 | + |
| 64 | +## Examples from Real Tasks |
| 65 | + |
| 66 | +### Task: "Remove wait-for command from tmux CLI agent" |
| 67 | + |
| 68 | +**Correct scope:** |
| 69 | +- Remove wait-for case from bash script |
| 70 | +- Update documentation strings to reference wait-idle instead |
| 71 | +- Update error message examples |
| 72 | +- Fix any compilation errors |
| 73 | + |
| 74 | +**Scope creep (avoid):** |
| 75 | +- Creating new documentation files about task validation |
| 76 | +- Adding template literal escaping guides |
| 77 | +- Creating terminal buffer management docs |
| 78 | +- Updating AGENTS.md with new doc references |
| 79 | + |
| 80 | +### Task: "Add redirect for /b/:hash" |
| 81 | + |
| 82 | +**Correct scope:** |
| 83 | +- Add one redirect rule to next.config.js |
| 84 | +- Verify it compiles |
| 85 | + |
| 86 | +**Scope creep (avoid):** |
| 87 | +- Adding tests for the redirect |
| 88 | +- Creating redirect management utilities |
| 89 | +- Adding analytics tracking |
| 90 | +- Documenting redirect patterns |
| 91 | + |
| 92 | +## When Additional Work IS Appropriate |
| 93 | + |
| 94 | +**Exception 1: Compilation/Runtime Errors** |
| 95 | +If your minimal change breaks compilation or causes runtime errors, fix those: |
| 96 | +```typescript |
| 97 | +// If removing wait-for breaks template literals, fix the escaping |
| 98 | +// If removing a function breaks imports, update the imports |
| 99 | +``` |
| 100 | + |
| 101 | +**Exception 2: Direct Dependencies** |
| 102 | +If the change requires updating direct references: |
| 103 | +```typescript |
| 104 | +// If removing wait-for, update help text that mentions it |
| 105 | +// If renaming a function, update its direct callers |
| 106 | +``` |
| 107 | + |
| 108 | +**Exception 3: Explicit "and" in Task** |
| 109 | +``` |
| 110 | +"Remove wait-for command and add documentation" // Two explicit tasks |
| 111 | +"Fix the bug and add a test" // Two explicit tasks |
| 112 | +``` |
| 113 | + |
| 114 | +## Validation Questions |
| 115 | + |
| 116 | +Before adding anything beyond the core task, ask: |
| 117 | +1. **Was this explicitly requested?** If no, don't add it. |
| 118 | +2. **Does the minimal change break without this?** If no, don't add it. |
| 119 | +3. **Is this a direct reference that must be updated?** If no, don't add it. |
| 120 | + |
| 121 | +## Communication Pattern |
| 122 | + |
| 123 | +When completing a task, clearly separate what was requested vs. what you considered: |
| 124 | + |
| 125 | +``` |
| 126 | +✅ Completed: Removed wait-for command from tmux CLI agent |
| 127 | +- Removed wait-for case from helper script |
| 128 | +- Updated documentation to use wait-idle |
| 129 | +- Fixed template literal escaping issues |
| 130 | +
|
| 131 | +💭 Considered but did not implement (not requested): |
| 132 | +- Adding comprehensive documentation about wait patterns |
| 133 | +- Creating validation guides |
| 134 | +- Refactoring related timing code |
| 135 | +``` |
| 136 | + |
| 137 | +## Key Principle |
| 138 | + |
| 139 | +**The best code change is the smallest one that accomplishes the exact goal.** Resist the urge to "improve while you're there" unless explicitly asked. Production systems value predictability and minimal change over comprehensive improvements. |
0 commit comments