Skip to content

nexu-io/open-design / plugins/_official/atoms/patch-edit

patch-edit

Verified

Apply one rewrite-plan step at a time as small reviewable file edits, never rewriting whole files when a localised change suffices.

FileKindSize
SKILL.mdskill md1.9 KB
open-design.jsonconfig867 B
---
name: patch-edit
description: Apply one rewrite-plan step at a time as small reviewable file edits, never rewriting whole files when a localised change suffices.
od:
  scenario: code-migration
  mode: edit
---

# Patch edit

Spec §20.3 / §21.3.2: code-migration / tune-collab cannot ship a
trustworthy diff when the agent rewrites whole files in one pass —
the reviewer can't audit the change. This atom enforces "one step
per turn, smallest possible localised edit".

## Inputs

- `plan/steps.json` from `rewrite-plan`.
- The current value of `iterations` (the daemon's per-stage counter).
- `code/index.json` for the file's known imports + neighbours.

## Output

The atom mutates files inside the project cwd via the `file-edit` tool.
After every iteration, it writes a per-step receipt:

```text
project-cwd/
└── plan/
    ├── steps.json (status updated: 'pending' → 'completed' | 'skipped')
    └── receipts/
        └── step-<id>.json    # { files: ['...'], diffSummary, rationale, completedAt }
```

## Convergence

The atom completes when every step in `plan/steps.json` is in a
terminal state (`completed` / `skipped`) OR `iterations >=
OD_MAX_DEVLOOP_ITERATIONS`. Use:

```jsonc
{
  "id": "patch-edit-loop",
  "atoms": ["patch-edit"],
  "repeat": true,
  "until": "plan.steps.terminal === plan.steps.total || iterations >= 8"
}
```

## Anti-patterns the prompt fragment forbids

- Rewriting an entire file when the rewrite-plan step is localised.
- Touching a file outside the step's `files[]`.
- Touching a `shell`-tier file when the step's `risk` is not
  `'high'` or the user hasn't confirmed.
- Skipping a step without a receipt + a rationale string.

## Status

Implemented by the daemon runner in
`apps/daemon/src/plugins/atoms/patch-edit.ts`. It validates step ownership and
risk, applies unified diffs with atomic writes, and records receipts and
progress.
receiving-code-reviewobra/superpowersUse when receiving code review feedback, before implementing suggestions, especially if feedback seems unclear or technically questionable - requires technical rigor and verification, not performative agreement or blind implementationStars: 322kUpdated Claude CodeCodexVerifiedInstall
requesting-code-reviewobra/superpowersUse when completing tasks, implementing major features, or before merging to verify work meets requirementsStars: 322kUpdated Claude CodeCodexVerifiedInstall
using-git-worktreesobra/superpowersUse when starting feature work that needs isolation from current workspace or before executing implementation plans - ensures an isolated workspace exists via native tools or git worktree fallbackStars: 322kUpdated Claude CodeCodexVerifiedInstall
verification-before-completionobra/superpowersUse when about to claim work is complete, fixed, or passing, before committing or creating PRs - requires running verification commands and confirming output before making any success claims; evidence before assertions alwaysStars: 322kUpdated Claude CodeCodexVerifiedInstall