# Agent replace edit silently deletes neighbouring blocks

> Agent replace edit silently deletes neighbouring blocks is an open-source agent skill for developer tools. Catches silent deletions when a subagent edits large files with repeated blocks. It is available on Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, Windsurf and Goose.

- **Kind:** Skill
- **Pricing:** Open source
- **Platforms:** Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, Windsurf, Goose
- **Website:** https://github.com/wan-huiyan/agent-traffic-control/tree/main/plugins/agent-traffic-control/skills/agent-replace-edit-silently-deletes-neighbouring-blocks
- **Repository:** https://github.com/wan-huiyan/agent-traffic-control
- **GitHub stars:** 5
- **License:** MIT
- **Skill name:** agent-replace-edit-silently-deletes-neighbouring-blocks
- **Collection:** https://github.com/wan-huiyan/agent-traffic-control
- **Categories:** [developer tools](https://ai-powered.com/categories/developer-tools)
- **Listing updated:** 2026-12-04

## About

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.

## What it can access

From a static check of the files on GitHub; nothing was run.

- [Instructions only, no scripts](https://github.com/wan-huiyan/agent-traffic-control/tree/HEAD/plugins/agent-traffic-control/skills/agent-replace-edit-silently-deletes-neighbouring-blocks)
- [License: MIT](https://github.com/wan-huiyan/agent-traffic-control/tree/HEAD/plugins/agent-traffic-control/skills/agent-replace-edit-silently-deletes-neighbouring-blocks)

## Features

- **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

## Install

### Claude Code

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):

```sh
/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`:

```sh
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.

### Codex

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

```sh
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.

### Cursor

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

```sh
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.

### Gemini CLI

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

```sh
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.

### VS Code

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

```sh
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.

### Other agents

Get the folder:

```sh
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.

## 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.

## Alternatives

- [Dispatched bash agent git checkout clobbers uncommitted edit](https://ai-powered.com/skills/dispatched-bash-agent-git-checkout-clobbers-uncommitted-edit): Dispatched bash agent git checkout clobbers uncommitted edit is an open-source agent skill for developer tools.
- [Agentsmd optimize](https://ai-powered.com/skills/agentsmd-optimize): Agentsmd optimize is an open-source agent skill for developer tools.
- [Safe execution edho ferdian](https://ai-powered.com/skills/safe-execution-edho-ferdian): Safe execution edho ferdian is an open-source agent skill for developer tools.
- [Safe change](https://ai-powered.com/skills/safe-change): Safe change is an open-source agent skill for developer tools.
- [Project retrofit](https://ai-powered.com/skills/project-retrofit): Project retrofit is an open-source agent skill for developer tools.
- [Code review](https://ai-powered.com/skills/code-review-martinffx): Code review is an open-source agent skill for developer tools.
- [Correct](https://ai-powered.com/skills/correct): Correct is an open-source agent skill for developer tools.
- [Take over resume](https://ai-powered.com/skills/take-over-resume): Take over resume is an open-source agent skill for developer tools.

---
Source: https://ai-powered.com/skills/agent-replace-edit-silently-deletes-neighbouring-blocks
