/simplify

Claude Code·Fable 5·pfleidi·2mo ago·11min·1 Checkpoint·12 file changes·+41/-59·35.9K tokens

/simplify → 4 cleanup agents in parallel → apply the fixes

You are improving the quality of the changed code, not hunting for bugs. Review it for reuse, simplification, efficiency, and altitude issues, then fix what you find. Do not look for correctness bugs — that is what /code-review is for.

Phase 0 — Gather the diff

Run git diff @{upstream}...HEAD (or git diff main...HEAD / git diff HEAD~1 if there's no upstream) to get the unified diff under review. If there are uncommitted changes, or the range diff is empty, also run git diff HEAD and include the working-tree changes in scope — the review often runs before the commit. If a PR number, branch name, or file path was passed as an argument, review that target instead. Treat this diff as the review scope.

Phase 1 — Review (4 cleanup agents in parallel)

Launch 4 independent review agents via the Agent tool, all in a single message so they run concurrently. Pass each agent the diff and one of the four angles below. Each returns its findings with file, line, a one-line summary, and the concrete cost (what is duplicated, wasted, or harder to maintain).

Reuse

Flag new code that re-implements something the codebase already has — Grep shared/utility modules and files adjacent to the change, and name the existing helper to call instead.

Simplification

Flag unnecessary complexity the diff adds: redundant or derivable state, copy-paste with slight variation, deep nesting, dead code left behind. Name the simpler form that does the same job.

Efficiency

Flag wasted work the diff introduces: redundant computation or repeated I/O, independent operations run sequentially, blocking work added to startup or hot paths. Also flag long-lived objects built from closures or captured environments — they keep the entire enclosing scope alive for the object's lifetime (a memory leak when that scope holds large values); prefer a class/struct that copies only the fields it needs. Name the cheaper alternative.

Altitude

Check that each change is implemented at the right depth, not as a fragile bandaid. Special cases layered on shared infrastructure are a sign the fix isn't deep enough — prefer generalizing the underlying mechanism over adding special cases.

Phase 2 — Apply the fixes

Wait for all four agents to complete, dedup findings that point at the same line or mechanism, and fix each remaining one directly. Skip any finding whose fix would change intended behavior, require changes well outside the reviewed diff, or that you judge to be a false positive — note the skip rather than arguing with it. Finish with a brief summary of what was fixed and what was skipped (or confirm the code was already clean).

2mo ago·51.9s

All four review agents are running (reuse, simplification, efficiency, altitude). I'll apply the fixes once they all report back.

2mo ago·7.0s

Efficiency review came back clean — the diff is nearly all deletions and every replacement path does the same or less I/O. Waiting on the other three agents (reuse, simplification, altitude).

2mo ago·7.4s

Reuse review found one minor item: a new subtest in refs_store_seam_test.go inlines the v1 branch ref construction (plus two imports) when the in-package test helper v1BranchRef() already exists. I'll fix that in the apply phase. Still waiting on simplification and altitude.

2mo ago·16.2s

Altitude review is back with one substantive finding: after this removal, the exported CheckpointVersionBranchV1 constant in api/checkpoint/errors.go (plus its re-export in aliases.go) survives only to seed policy defaults in checkpointpolicy — which already owns that vocabulary (branchV1Format). The deeper fix is to move the default into checkpointpolicy and delete the api const and alias. Its second note (the readSummaryFromBlob passthrough) it judged defensible to keep since it mirrors the Metadata sibling — I'll skip that one.

One agent (simplification) still running; I'll dedup and apply once it finishes.

2mo ago·3m

Everything passes: go build ./... clean, focused tests for checkpointpolicy, checkpoint, and api/checkpoint all ok, and mise run fmt && mise run lint reports 0 issues.

Summary

All four review agents ran (reuse, simplification, efficiency, altitude); efficiency came back clean, and the other three produced four findings, deduplicated to three fixes.

Fixed:

  1. Moved the branch-v1 default into checkpointpolicy (flagged by both simplification and altitude). After this branch removed the checkpoint_version metadata field, the exported CheckpointVersionBranchV1 constant in api/checkpoint/errors.go no longer described anything in that package — its only consumer was checkpointpolicy's defaults, reached through a two-hop re-export via cmd/entire/cli/checkpoint/aliases.go. The constant now lives in checkpointpolicy/format.go next to the format vocabulary that already owns "branch-v1"; the api const, the alias, and policy.go's checkpoint import are deleted, and the five policy test files reference checkpointpolicy.CheckpointVersionBranchV1 directly. This mirrors what the branch already did to the sibling CheckpointVersionRefsV1.

  2. Deleted persistent_reader.go. The diff had removed normalizeCheckpointSummary, leaving that file holding only the 3-line AuthorReader interface under a now-misleading name. The interface moved into persistent.go, next to the Author type it returns.

  3. Seam test now uses the existing v1BranchRef() helper instead of inlining plumbing.NewBranchReferenceName(paths.MetadataBranchName), dropping the two imports that existed solely for that one line.

Skipped: readSummaryFromBlob being a one-line pass-through to readJSONFromBlob — it exactly mirrors the pre-existing readMetadataFromBlob wrapper, so the named wrapper is the consistent form; both agents that noticed it agreed it's defensible to keep.

The changes are uncommitted in the working tree for your review.

commit the changes

2mo ago·39.2s

Committed as c8d3cab9c5 — "move branch-v1 default into checkpointpolicy", 12 files, +41/−59. Verification was already green from the simplify pass (build, focused tests, fmt+lint all clean) and nothing changed since. The commit is local only; not pushed.