rewrite
Skill9 starsChanged 7 months agoApache-2.0View on GitHub
Force a full-file rewrite (Write) instead of patch (Edit) when Edit keeps failing or diff is large. Context rot mitigation — use when Edit has failed ≥2× on same file, or when estimated diff >30% of file size.
8 other projects use a version of this.
Adopted by
Most recently taken up by
- mangollc/claude-SDR-Manager-plugintheir own version, first seen Nov 1, 2026
- saeedvaziry/skillstheir own version, first seen Oct 25, 2026
- holt-os/holttheir own version, first seen Oct 17, 2026
- assaio/unwordytheir own version, first seen Sep 21, 2026
- rainday/smart-blog-skillstheir own version, first seen May 15, 2026
- linfengchen/skillstheir own version, first seen Apr 19, 2026
Other versions8 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 8
- MJbae/awesome-novel-studio★ 148same name
- alanalvestech/hitank★ 38same name
- rainday/smart-blog-skills★ 35same name
- saeedvaziry/skills★ 13same name
- holt-os/holt★ 7same name
- linfengchen/skills★ 4same name
- assaio/unwordy★ 1same name
- mangollc/claude-SDR-Manager-plugin★ 1same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository27 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- cli/CLAUDE.mdCLAUDE.md
- control-plane-api/CLAUDE.mdCLAUDE.md
- control-plane-ui/CLAUDE.mdCLAUDE.md
- e2e/CLAUDE.mdCLAUDE.md
- portal/CLAUDE.mdCLAUDE.md
- stoa-gateway/CLAUDE.mdCLAUDE.md
- analyticsSkill
- cartoSkill
- ci-debugSkill
- ci-fixSkill
- competitive-watchSkill
- councilSkill
- decomposeSkill
- extractSkill
- fill-cycleSkill
- generate-backlogSkill
- impactSkill
- memory-consolidateSkill
- monitor-cdSkill
- parallel-reviewSkill
- pr-guardianSkill
- roadmapSkill
- spec-drivenSkill
- sync-planSkill
- verify-megaSkill
The file
We split this skill into the rules it gives an agent
12 rules. 0 are common, 7 are distinctive, and 5 are very specific to this project.
0
Common
Most of the 6 edited versions we read keep these.
7
Distinctive
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
- Very specific: line 31
If INTENT is empty, ask the user: "What should the rewrite accomplish?
- Very specific: line 34
Always Read the full file before rewriting.
- Very specific: line 40
If consecutive_fails ≥ 2, the rewrite is warranted.
- Distinctive: line 46
Import structure and file-level conventions
- Very specific: line 56
Use the Write tool with the full new content.
- Distinctive: line 59
Run the relevant check for the file type:
- Very specific: line 65
If the file has tests nearby (*_test.*, *.test.*, *.spec.*), run them.
- Distinctive: line 75
Do NOT rewrite a file whose purpose you don't understand.
- Distinctive: line 76
Do NOT rewrite while the main context is >70% full — delegate to a subagent instead (the pollution bias applies to rewrites too).
- Distinctive: line 77
Do NOT bundle unrelated changes into the rewrite.
- Distinctive: line 78
Do NOT remove comments that carry historical/compliance context (e.g.
- Distinctive: line 79
Do NOT rewrite test files without running them after — silent test deletion is a known failure mode.
“Common” is measured: kept by at least 6 in 10 of the 6 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Rewrite — $ARGUMENTS
Invoked when Edit (patch) is the wrong tool. Research shows search/replace fails 20-30% on evolved code, and accumulated failed patches poison the context (Liu et al. "Lost in the Middle"; Databricks Mosaic). See
feedback_rewrite_after_fail.md.
When to use this skill
Triggered automatically via the hook post-edit-failure-tracker.sh at 2 consecutive Edit failures. Also invoke manually when:
- Diff estimated >30% of the file size
- Refactoring where structure changes, not just content
- File is small-to-medium (≤800 lines) and a clean rewrite is cheaper than hunting for correct search/replace anchors
- User says "just rewrite it"
Do NOT use for:
- Single-line changes (use Edit)
- Files >1500 lines (split first, or delegate to subagent)
- Files you haven't read yet in this session (read first, understand first)
Workflow
Step 1 — Parse arguments
Split $ARGUMENTS into:
FILE_PATH(first token, absolute path)INTENT(remainder — what the rewrite should accomplish)
If INTENT is empty, ask the user: "What should the rewrite accomplish? (e.g. 'fix the auth middleware bug', 'add tenant filtering')". Do NOT guess the intent from context alone.
Step 2 — Read the current file
Always Read the full file before rewriting. If >1500 lines, stop and suggest splitting or subagent delegation instead.
Step 3 — Check pollution signal
jq --arg path "$FILE_PATH" '[.[] | select(.path == $path)] | .[0]' .claude/state/edit-attempts.jsonIf consecutive_fails ≥ 2, the rewrite is warranted. If total ≥ 5 but consecutive_fails < 2, consider whether a subagent with fresh context would be better than an inline rewrite (Main context already has noise).
Step 4 — Rewrite strategy
Preserve by default:
- Public API surface (exported symbols, function signatures if referenced elsewhere)
- Import structure and file-level conventions
- Comments that explain non-obvious WHY (delete comments that explain WHAT)
- Type annotations, docstrings where they exist
Change per INTENT:
- Fix the bug described
- Refactor the internal logic
- Simplify control flow
Step 5 — Write the file
Use the Write tool with the full new content. Never emit partial content or placeholders like // ... rest unchanged.
Step 6 — Verify
Run the relevant check for the file type:
.py:ruff check <file> && ruff format --check <file>(or let the post-edit-format hook run).rs:rustfmt --check <file>+cargo check -p <crate>if feasible.ts|.tsx|.js|.jsx:npx prettier --check <file>.go:go vet ./... && gofmt -l <file>
If the file has tests nearby (*_test.*, *.test.*, *.spec.*), run them.
Step 7 — Reset the tracker
jq --arg path "$FILE_PATH" 'del(.[] | select(.path == $path))' .claude/state/edit-attempts.json > /tmp/et.json && mv /tmp/et.json .claude/state/edit-attempts.jsonRemoves the failure counter for this file so the next session starts clean.
Anti-patterns
- Do NOT rewrite a file whose purpose you don't understand. Read + grep callers first.
- Do NOT rewrite while the main context is >70% full — delegate to a subagent instead (the pollution bias applies to rewrites too).
- Do NOT bundle unrelated changes into the rewrite. Stick to the stated INTENT.
- Do NOT remove comments that carry historical/compliance context (e.g. "kept for backwards compat with X", "regression for CAB-XXXX") — these have load-bearing information.
- Do NOT rewrite test files without running them after — silent test deletion is a known failure mode.
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.

