incremental-writes
Skill2 starsChanged 10 months agoMITView on GitHub
Decomposes large file writes into multiple targeted edits to avoid token overflows, partial writes, and opaque diffs. Use when creating or editing files larger than ~150 lines, when rewriting a large section of an existing file, or when asked to "write this file", "generate this module", or "scaffold this class".
In this repository4 other files it gives its agents.
- brand-scoutSkill
- jest-testSkill
- llms-txtSkill
- type-craftSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
14 rules. About 0 are common, 9 are distinctive, and 5 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈9
Distinctive · estimate
This author's own choices. Worth a look.
5
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 14
Always decompose file work into multiple focused tool calls rather than one large write.
- Distinctive: line 25
When in doubt about whether a new file will be large, default to skeleton-first.
- Very specific: line 29
Prefer
StrReplaceoverWritefor existing files: Only use Write on an existing file when the entire file must be replaced and no … - Distinctive: line 33
If the content is longer, break it into sections and apply them sequentially.
- Distinctive: line 34
Read before editing: Always read the target file (or the relevant section) before making any edit to an existing file.
- Distinctive: line 41
Read the file (or the relevant range) first.
- Very specific: line 43
Use StrReplace with a old_string that uniquely identifies that region.
- Distinctive: line 46
Never reconstruct the entire file from scratch just to change a few lines.
- Distinctive: line 58
Use the skeleton-first pattern:
- Distinctive: line 62
Keep this under ~80 lines.
- Distinctive: line 89
When sections have dependencies (e.g., a helper used by two methods), write the dependency first.
- Very specific: line 100
Read the file to locate createUser and its current error strings.
- Very specific: line 132
Read the file to capture the full current parseConfig function body.
- Very specific: line 134
If the new implementation is > 150 lines, split it: replace with a shorter version first, then StrReplace the placeholder sections.
≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Incremental Writes
Always decompose file work into multiple focused tool calls rather than one large write. Keep each call to a single logical change.
When to Apply
Apply these rules on every task that involves writing or editing files — not only when a file is already known to be large:
- Any edit to an existing file → use
StrReplace; only fall back toWritewhen the entire file must be replaced and no targeted edit is possible - Creating any new file → estimate scope first; if likely >150 lines, use skeleton-first
- Refactoring or rewriting a section → target the minimal region, apply incrementally
When in doubt about whether a new file will be large, default to skeleton-first.
Rules
- Prefer
StrReplaceoverWritefor existing files. Only useWriteon an existing file when the entire file must be replaced and no targeted edit is possible (e.g.StrReplacecannot find a unique match). - Never write more than ~150 lines in a single
WriteorStrReplacecall. If the content is longer, break it into sections and apply them sequentially. - Read before editing. Always read the target file (or the relevant section) before making any edit to an existing file.
- One logical change per call. Each
StrReplaceshould represent one coherent change: a function, a config block, an import group, etc.
Strategy: Editing Existing Files
- Read the file (or the relevant range) first.
- Identify the minimal region that needs to change.
- Use
StrReplacewith aold_stringthat uniquely identifies that region. - Apply one change per call. Chain calls for multiple independent changes.
Never reconstruct the entire file from scratch just to change a few lines.
Example decomposition for a 3-function edit:
Call 1: StrReplace — update function A
Call 2: StrReplace — update function B
Call 3: StrReplace — add import at topStrategy: Creating New Large Files
Use the skeleton-first pattern:
- Write the skeleton — create the file with top-level structure only: stubs, empty functions, section headers, placeholder comments. Keep this under ~80 lines.
- Fill each section — use
StrReplaceto replace each placeholder with its full implementation, one section at a time. - Verify — read the completed file and fix any issues with targeted
StrReplacecalls.
Call 1: Write — skeleton (imports, class shell, empty methods)
Call 2: StrReplace — implement method A
Call 3: StrReplace — implement method B
Call 4: StrReplace — implement method C
Call 5: StrReplace — fill in config blockDecomposition Patterns
Choose a split boundary that matches the file's natural structure:
| File type | Split by |
| Class / module | One method or property group per call |
| Config file | One top-level key block per call |
| React component | Component shell → JSX → hooks → helpers |
| Test file | One describe block per call |
| Long script | Imports → constants → functions → main block |
| Markdown / docs | One major section (## heading) per call |
When sections have dependencies (e.g., a helper used by two methods), write the dependency first.
Examples
Example 1: Editing an existing file
User says: "Add input validation to the createUser function and update
its error messages."
Actions:
- Read the file to locate
createUserand its current error strings. StrReplace— replace the function body with the validated version.StrReplace— update error message constants if they live elsewhere.
Result: Two focused edits; the rest of the file is untouched.
Example 2: Creating a new 300-line service module
User says: "Create a PaymentService class with methods for charging,
refunding, and webhooks."
Actions:
Write— skeleton with class declaration, constructor stub, and three empty method stubs (~40 lines).StrReplace— implementcharge()method (~60 lines).StrReplace— implementrefund()method (~50 lines).StrReplace— implementhandleWebhook()method (~70 lines).StrReplace— add private helper methods and final imports (~40 lines).
Result: File is built in five coherent steps; each step is reviewable and recoverable if something goes wrong.
Example 3: Rewriting a large section inside an existing file
User says: "Rewrite the parseConfig function — it needs to handle nested
keys now."
Actions:
- Read the file to capture the full current
parseConfigfunction body. StrReplace— replace the entire function with the new implementation. If the new implementation is > 150 lines, split it: replace with a shorter version first, thenStrReplacethe placeholder sections.
Result: Only parseConfig changes; nothing else in the file is at risk.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

