Skip to content
Skill

Agent replace edit silently deletes neighbouring blocks

Catches silent deletions when a subagent edits large files with repeated blocks

Agent replace edit silently deletes neighbouring blocks is an open-source agent skill for developer tools. It is available on Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, Windsurf and Goose.

Scripts
None
Platforms
Claude Code, Codex, Cursor
GitHub stars
5
Last commit
License
MIT
Listing updated

Similar skills

About Agent replace edit silently deletes neighbouring blocks

This skill covers a specific failure in agent-driven editing: a search-and-replace that matches text spanning several similar blocks in a large file, removing unrelated views, types or helpers while the agent reports success. It walks through snapshotting the file's declared outline and line count before an agent runs, writing the intended removals into the plan, and diffing the outline and deletion counts afterwards.

The workflow uses plain shell commands such as wc, grep, sed, diff and git diff --stat, with a git checkout to restore the file when the check fails. Recovery means redoing the change by hand or re-dispatching the agent with an anchor string confirmed to occur exactly once in the file, rather than patching the damaged file.

It expects a git repository and a file where declarations can be matched by keywords like struct, class, func or def. Its notes suggest asking the agent to paste the outline diff rather than a summary.

When your agent uses it

A builder subagent made a search-and-replace edit to a large shared file, and its report says the change is done. In a file with several similar blocks, the text it matched can start in one block and end in another, so the replace removes everything in between: the tail of one view, a whole other view, helpers. Nothing errors and the file may still compile. Use after any agent edit to a large file with repeated structure (views, handlers, test classes, config sections), when an agent's diff shows far more deleted lines than the plan called for, or when a type or function you did not ask about is gone. Diff the file's outline (declared types and functions) and line counts before and after against the plan's intended removals.

From the skill's SKILL.md. Your agent reads this description to decide when to load the skill.

What it can access

From a static check of its 1 file (6 KB) on GitHub on 4 December 2026. Nothing was run. Read the files before you install a skill: it can tell your agent to run anything its tools allow.

Check another skill before you install it.

Install

This skill ships in the agent-traffic-control plugin. In Claude Code, add the marketplace and install the plugin (it may include other skills too):

/plugin marketplace add wan-huiyan/agent-traffic-control
/plugin install agent-traffic-control@wan-huiyan-agent-traffic-control

Or copy only this skill to ~/.claude/skills/agent-replace-edit-silently-deletes-neighbouring-blocks:

tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/wan-huiyan/agent-traffic-control.git "$tmp" &&
mkdir -p ~/.claude/skills &&
rm -rf ~/.claude/skills/agent-replace-edit-silently-deletes-neighbouring-blocks &&
cp -R "$tmp/plugins/agent-traffic-control/skills/agent-replace-edit-silently-deletes-neighbouring-blocks" ~/.claude/skills/agent-replace-edit-silently-deletes-neighbouring-blocks &&
rm -rf "$tmp"

For one project only, put the folder in .claude/skills/agent-replace-edit-silently-deletes-neighbouring-blocks inside it instead.

Claude Code docs on skills

Copy the skill folder to ~/.agents/skills/agent-replace-edit-silently-deletes-neighbouring-blocks to use it in every repository:

tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/wan-huiyan/agent-traffic-control.git "$tmp" &&
mkdir -p ~/.agents/skills &&
rm -rf ~/.agents/skills/agent-replace-edit-silently-deletes-neighbouring-blocks &&
cp -R "$tmp/plugins/agent-traffic-control/skills/agent-replace-edit-silently-deletes-neighbouring-blocks" ~/.agents/skills/agent-replace-edit-silently-deletes-neighbouring-blocks &&
rm -rf "$tmp"

For one repository only, put the folder in .agents/skills/agent-replace-edit-silently-deletes-neighbouring-blocks inside it instead.

Codex docs on skills

Copy the skill folder to ~/.cursor/skills/agent-replace-edit-silently-deletes-neighbouring-blocks to use it in every project:

tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/wan-huiyan/agent-traffic-control.git "$tmp" &&
mkdir -p ~/.cursor/skills &&
rm -rf ~/.cursor/skills/agent-replace-edit-silently-deletes-neighbouring-blocks &&
cp -R "$tmp/plugins/agent-traffic-control/skills/agent-replace-edit-silently-deletes-neighbouring-blocks" ~/.cursor/skills/agent-replace-edit-silently-deletes-neighbouring-blocks &&
rm -rf "$tmp"

For one project only, put the folder in .cursor/skills/agent-replace-edit-silently-deletes-neighbouring-blocks inside it instead.

Cursor docs on skills

Run in a terminal (add --scope workspace to install it for the current workspace only):

gemini skills install https://github.com/wan-huiyan/agent-traffic-control.git --path plugins/agent-traffic-control/skills/agent-replace-edit-silently-deletes-neighbouring-blocks

Or copy the folder to ~/.gemini/skills/agent-replace-edit-silently-deletes-neighbouring-blocks yourself.

Gemini CLI docs on skills

For GitHub Copilot in VS Code, copy the skill folder to ~/.copilot/skills/agent-replace-edit-silently-deletes-neighbouring-blocks:

tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/wan-huiyan/agent-traffic-control.git "$tmp" &&
mkdir -p ~/.copilot/skills &&
rm -rf ~/.copilot/skills/agent-replace-edit-silently-deletes-neighbouring-blocks &&
cp -R "$tmp/plugins/agent-traffic-control/skills/agent-replace-edit-silently-deletes-neighbouring-blocks" ~/.copilot/skills/agent-replace-edit-silently-deletes-neighbouring-blocks &&
rm -rf "$tmp"

For one project only, put the folder in .github/skills/agent-replace-edit-silently-deletes-neighbouring-blocks inside it instead.

VS Code docs on skills

Get the folder:

git clone --depth 1 https://github.com/wan-huiyan/agent-traffic-control.git

Then copy agent-traffic-control/plugins/agent-traffic-control/skills/agent-replace-edit-silently-deletes-neighbouring-blocks into your agent's skills folder as agent-replace-edit-silently-deletes-neighbouring-blocks. Agents that support SKILL.md read one folder per skill.

The SKILL.md format

What it does

Outline snapshot before edits
Records the file's declared types and functions and its line count before an agent runs.
Planned removal checklist
Ties each expected deletion to a named declaration and an approximate line count.
Post-edit outline diff
Compares declarations and line counts after the edit against the planned removals.
Restore and redo procedure
Restores the file from git and reapplies the change using an anchor that occurs once.
Unique match check
Uses grep to confirm the matched text appears exactly once before replacing.

Good for

  • Check that a subagent's edit to a large shared file deleted only the planned lines
  • Compare declared classes and functions in a file before and after an automated change
  • Restore a file from git after an edit removed unrelated views or helpers
  • Verify a refactor of repeated view or test blocks did not drop neighbouring code

Agent replace edit silently deletes neighbouring blocks FAQ

When should I use Agent replace edit silently deletes neighbouring blocks?

After an agent edits a large file with repeated structure, when its diff shows far more deleted lines than planned, or when a declaration you did not ask about has disappeared.

Does Agent replace edit silently deletes neighbouring blocks run any scripts?

No scripts are included. It relies on shell commands such as wc, grep, sed, diff and git.

What does Agent replace edit silently deletes neighbouring blocks change in my project?

It does not edit code itself. It describes snapshot and diff checks, and a git checkout to restore a file when the check fails.

How do I install Agent replace edit silently deletes neighbouring blocks in Claude Code?

Copy the skill folder from GitHub to ~/.claude/skills/agent-replace-edit-silently-deletes-neighbouring-blocks to use it in all your projects, or to .claude/skills/agent-replace-edit-silently-deletes-neighbouring-blocks in one project. Or install the agent-traffic-control plugin, which includes it: /plugin marketplace add wan-huiyan/agent-traffic-control, then /plugin install agent-traffic-control@wan-huiyan-agent-traffic-control.

Does Agent replace edit silently deletes neighbouring blocks run scripts?

No. It is instructions only, with no scripts. This comes from a static check of the files on GitHub; nothing was run. Read the files before you install it.

Which AI agents can use Agent replace edit silently deletes neighbouring blocks?

Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, Windsurf and Goose. Each reads skills in the SKILL.md format from its own folder; the install steps on this page list them.

What are the best alternatives to Agent replace edit silently deletes neighbouring blocks?

The closest alternatives to Agent replace edit silently deletes neighbouring blocks are Dispatched bash agent git checkout clobbers uncommitted edit, Agentsmd optimize, Safe execution edho ferdian, Safe change and Project retrofit.

Where this comes from

  • Description: from the skill's own SKILL.md.

More from wan-huiyan/agent-traffic-control