Docs Sync After Edits
FeaturedOn demandAbout Docs Sync After Edits
This loop updates documentation after code has been edited. Each round compares the current branch with main to find changed files, revises the docs those changes affect, and checks the result against the code.
Key features
- 01Finds the change scope with git diff main...HEAD --name-only
- 02Manual trigger, so the user decides when it starts
- 03Capped at 3 rounds to avoid endless edits
- 04Updated docs must be verified before the loop finishes
Use cases
- 01Finishing documentation after a feature branch is done
- 02Cleaning up outdated descriptions after a refactor or rename
- 03Confirming no docs were missed before opening a pull request
- Goal
- Documentation matches the code changes on the current branch.
- Exit when
- Stop once every affected doc has been updated and verified.
- Between iterations run
- git diff main...HEAD --name-only
Launch prompt
Paste into Cursor. The agent repeats the steps below until the exit condition is met.
Start the "Docs Sync After Edits" loop. Goal: Documentation matches the code changes on the current branch. Max iterations: 3. Step 1: List changed files — Use the output of git diff main...HEAD --name-only to see which files the branch changed relative to main. From that, decide which docs may be affected. Step 2: Update affected docs — For each affected doc, revise descriptions, examples and references to reflect the latest code. Leave content untouched when nothing relevant changed. Step 3: Verify docs against code — Compare the revised docs with the actual code item by item. If any mismatch remains, start another round; if everything agrees, end the loop. Between iterations run: `git diff main...HEAD --name-only` Exit when: Stop once every affected doc has been updated and verified.
Steps
Each round runs in order; if the exit condition isn’t met, another round starts, up to 3.
Use the output of git diff main...HEAD --name-only to see which files the branch changed relative to main. From that, decide which docs may be affected.
For each affected doc, revise descriptions, examples and references to reflect the latest code. Leave content untouched when nothing relevant changed.
Compare the revised docs with the actual code item by item. If any mismatch remains, start another round; if everything agrees, end the loop.
Supported agents
Coding agents that can run this loop directly.