agentleFS
chrisduvillardchrisduvillard/codex-engineering-skills/skills/harvest-agent-branches/SKILL.md

harvest-agent-branches

Skill1 starsChanged 3 months agoMITView on GitHub

Inspect and recover coherent work from stale, divergent, abandoned, or oversized agent branches and worktrees without overwriting newer target changes. Use before a risky wholesale merge.

The file

Show its rules and text

We split this skill into the rules it gives an agent

27 rules. About 0 are common, 26 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈26

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Treat an agent branch as evidence about intended changes, not as a patch that deserves to land whole.

    line 8
  2. Distinctive:

    Keep inspection read-only.

    line 13
  3. Distinctive:

    Delete a branch or worktree only when explicitly requested and after establishing durable recovery.

    line 14
  4. Distinctive:

    Stop for a user decision when it is unclear whether a source feature is still wanted.

    line 15
  5. Distinctive:

    Read repository instructions, glossary or context files, ADRs, architecture notes, current plans, and available architecture indexes before …

    line 19
  6. Distinctive:

    every worktree path, branch, HEAD, and dirty state.

    line 29
  7. Distinctive:

    Use read-only Git evidence such as:

    line 33
  8. Distinctive:

    Before implementing a slice, classify every path in that slice and its dependency closure individually.

    line 52
  9. Distinctive:

    Before declaring the whole branch harvested or deleting it, classify every changed path individually.

    line 53
  10. Distinctive:

    Create a compact ledger:

    line 55
  11. Distinctive:

    Do not let uninspected paths disappear from the inventory.

    line 60
  12. Distinctive:

    Treat a target-untouched path as eligible for whole-file or commit transfer only after confirming the source change is coherent and …

    line 62
  13. Distinctive:

    Treat a source-side deletion as a possible regression.

    line 64
  14. Distinctive:

    Read the actual diffs, especially deletions.

    line 68
  15. Distinctive:

    When asked for the first slice, choose the smallest independently valuable or enabling behavior with a complete dependency closure and low …

    line 83
  16. Distinctive:

    Before splitting or moving modules, search test patch targets and imports.

    line 85
  17. Very specific:

    Use an isolated worktree pinned to the target SHA unless the current workspace is already a clean, dedicated worktree for this task.

    line 98
  18. Distinctive:

    Keep slices small enough to review and revert independently.

    line 100
  19. Distinctive:

    Run compatibility tests against previous persisted shapes for reader changes.

    line 110
  20. Distinctive:

    Run database-specific checks when SQLite cannot represent locks, JSON operators, defaults, constraints, or cascades.

    line 111
  21. Distinctive:

    Run platform-specific checks on the real platform for filesystem identity, process, lock, launcher, or path behavior.

    line 112
  22. Distinctive:

    Run contract, golden, architecture-boundary, and end-to-end tests for cross-cutting owners.

    line 113
  23. Distinctive:

    Before deleting any source ref:

    line 119
  24. Distinctive:

    Verify the recovery route resolves to the recorded tip.

    line 124
  25. Distinctive:

    Delete only the exact authorized ref.

    line 125
  26. Distinctive:

    Do not remove the isolated worktree until it is clean and every useful artifact is committed, copied to an approved location, or …

    line 128
  27. Distinctive:

    Do not describe a partial port as a completed branch harvest while unclassified source changes remain.

    line 142

≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Harvest Agent Branches

Treat an agent branch as evidence about intended changes, not as a patch that deserves to land whole. Transfer coherent intent onto the current target one reviewable slice at a time.

Bound the authority

  1. Distinguish inspection, local harvesting, publication, deployment, and cleanup.
  2. Keep inspection read-only. Treat permission to implement as permission for local branch/worktree changes only; do not infer permission to push, open a PR, deploy, mutate live data, or delete refs.
  3. Delete a branch or worktree only when explicitly requested and after establishing durable recovery.
  4. Stop for a user decision when it is unclear whether a source feature is still wanted. Do not rescue work merely because it exists.

Read the target's rules first

Read repository instructions, glossary or context files, ADRs, architecture notes, current plans, and available architecture indexes before classifying changes. Use the repository's vocabulary and preserve its accepted decisions.

Pin the evidence

Resolve and record before editing:

  • source ref and full commit SHA;
  • target ref and full commit SHA;
  • merge-base SHA;
  • every worktree path, branch, HEAD, and dirty state;
  • relevant remote or PR recovery ref;
  • whether either ref moved during the investigation.

Use read-only Git evidence such as:

git rev-parse --verify 'source-ref^{commit}'
git rev-parse --verify 'target-ref^{commit}'
git merge-base source-sha target-sha
git worktree list --porcelain
git log --left-right --cherry-pick --oneline target-sha...source-sha
git diff --name-status -M -C merge-base..source-sha
git diff --name-status -M -C merge-base..target-sha

Inspect status inside every relevant worktree. Never stash, reset, clean, switch, or overwrite a shared checkout. Preserve unrelated dirty and untracked files. Fetch an exact missing ref when needed; avoid pruning unrelated refs.

Build a path matrix

Inventory the whole branch before choosing a transfer method. Match detail to the request:

  • For an initial comparison, cleanup assessment, or request for the first slice, cluster every changed path by concern and inspect the proposed slice path-by-path.
  • Before implementing a slice, classify every path in that slice and its dependency closure individually.
  • Before declaring the whole branch harvested or deleting it, classify every changed path individually.

Create a compact ledger:

Path or concernSource changeTarget change since baseContract roleDecisionSlice

Do not let uninspected paths disappear from the inventory. Include deletions, renames, migrations, generated files, tests, configuration, and documentation.

  • Treat a target-untouched path as eligible for whole-file or commit transfer only after confirming the source change is coherent and adjacent contracts did not change.
  • For a path changed on both sides, inspect the base, source, current target, and git log merge-base..target -- path. Port intent additively onto the target.
  • Treat a source-side deletion as a possible regression. Prove zero callers or identify the current replacement before carrying it over.
  • Trace both sides of a rename; do not let rename detection hide a delete-and-recreate semantic change.
  • Regenerate derived files from their current owner inputs instead of copying stale generated output.

Read the actual diffs, especially deletions. File counts and diff statistics orient the investigation but cannot establish safety.

Decompose by behavior

Define each slice as one observable capability or root-cause fix. Include its complete dependency closure:

  • implementation and public entrypoint;
  • callers, adapters, imports, and compatibility shims;
  • tests and hand-built fixtures;
  • schema migrations and model changes;
  • configuration, examples, generated outputs, and operator documentation;
  • terminology or architectural decisions that require glossary or ADR updates.

Mark every source change as harvest, superseded, skip intentionally, or needs user decision. Do not leave unexplained residue.

When asked for the first slice, choose the smallest independently valuable or enabling behavior with a complete dependency closure and low target overlap. "First" means safest useful landing order, not earliest source commit or smallest raw diff.

Before splitting or moving modules, search test patch targets and imports. Preserve intentional monkeypatch seams at their old public location or replace hidden module-global reads with explicit injection. Do not assume a green test exercised a moved patch target.

For persisted data or wire-format readers, include at least one fixture written by hand in the previous format. Never let every compatibility fixture pass through the new writer under test.

Choose the least risky transfer

Prefer, in order:

  1. Reimplement the source intent against current target abstractions when the target evolved materially.
  2. Apply a focused patch or use a no-commit cherry-pick for a coherent commit, then review every resulting line.
  3. Transfer a whole file only when target history proves it remained untouched and the file has no stale coupled assumptions.
  4. Merge the whole branch only when it is current, cohesive, independently reviewed, and the user explicitly wants that strategy.

Use an isolated worktree pinned to the target SHA unless the current workspace is already a clean, dedicated worktree for this task. Use a fresh codex/ branch by default. Never develop directly in a shared primary checkout.

Keep slices small enough to review and revert independently. Land prerequisites before dependents. Preserve current target behavior unless the slice explicitly changes it.

Prove the harvest

Establish a target baseline before modification, run focused checks while iterating, then run the repository's authoritative gate for a substantive slice.

Make every verification result state what it examined: exact SHA, platform, resolved root, files or tests collected, artifacts or rows sampled, and relevant configuration. Treat zero-input, wrong-root, self-matching process, stale-SHA, or new-writer-only checks as no evidence.

Select additional proof by risk:

  • Run compatibility tests against previous persisted shapes for reader changes.
  • Run database-specific checks when SQLite cannot represent locks, JSON operators, defaults, constraints, or cascades.
  • Run platform-specific checks on the real platform for filesystem identity, process, lock, launcher, or path behavior.
  • Run contract, golden, architecture-boundary, and end-to-end tests for cross-cutting owners.
  • Inspect integrated-target CI after landing when remote publication is authorized; a green source PR does not prove the combined target.

Preserve recovery before cleanup

Before deleting any source ref:

  1. Record its full tip SHA and original ref name.
  2. Confirm which slices landed and which were intentionally skipped.
  3. Establish a durable recovery route such as a retained branch/tag, an existing PR ref with a documented hosting-retention assumption, or an explicitly authorized bundle. Do not call an unreachable local object durable recovery. If recovery must be indefinite, do not rely on a PR ref alone unless its retention is guaranteed; prefer an authorized tag or archived bundle.
  4. Verify the recovery route resolves to the recorded tip.
  5. Delete only the exact authorized ref; never use broad patterns.
  6. Report what was removed, where the recovery evidence lives, and how long it is expected to remain available.

Do not remove the isolated worktree until it is clean and every useful artifact is committed, copied to an approved location, or intentionally discarded.

Hand off clearly

Lead with what was actually harvested. Include:

  • source, target, and merge-base SHAs;
  • landed slices and their commits or changed paths;
  • superseded and intentionally skipped material with reasons;
  • baseline and verification results with scope counts;
  • unresolved conflicts, compatibility risks, and decisions still needed;
  • exact recovery refs for any retained or deleted branch;
  • confirmation that production, deployment, and unrelated worktrees were untouched unless separately authorized.

Do not describe a partial port as a completed branch harvest while unclassified source changes remain.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.