agentleFS
degdeg/beads-utils/skills/finalize/SKILL.md

finalize

Skill2 starsChanged 6 days agoMITView on GitHub

Finalize work on one bead — self-review, refactor, add tests, run lint and tests until clean, get a senior review, then commit with the user's approval and close the bead. Use for /finalize, or when the user says a task's work is done. Runs once per bead; /close-shop closes the session.

  • Commits and pushes

23 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use simplify, debug and 3 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • Hugging FaceSkill

    simplify

    Refactor code after tests pass. The "Refactor" phase of Red-Green-Refactor.

    Also in 3 projects that use this

  • AnthropicSkill

    debug

    Structured debugging session — reproduce, isolate, diagnose, and fix. Trigger with an error message or stack trace, "this works in staging but not prod", "something broke after the deploy", or when behavior diverges from expected and the cause isn't obvious.

    Also in 3 projects that use this

  • Microsoft AzureSkill

    verify

    End-to-end app testing pipeline for browser-based web apps on cloud browsers via Azure Playwright Workspaces: verify the live app, author tests for working flows, heal failing tests, then re-run with video and produce one consolidated report. Three phases (app verification, test authoring, test healing) plus a scoped final sanity run; each phase emits a sub-report. Use when asked to "verify my app", "make sure my app works and has good test coverage", "do a full QA pass", "add tests where I'm missing coverage", "fix failing tests and add new ones", "smoke test before deploy", "QA my deployment", or any combined verify-and-test ask. Requires Azure CLI (`az login`) and a Playwright Workspace resource ID — bootstraps configs on first invocation. Browser-based web apps with Playwright only — not for unit/API tests, native mobile/desktop, load/perf, or full accessibility audits.

    Also in 3 projects that use this

  • SentrySkill

    commit

    Create commit messages following Sentry conventions. Use when committing code changes, writing commit messages, or formatting git history. Follows conventional commits with Sentry-specific issue references.

    Also in 3 projects that use this

  • MicrosoftSkill

    handoff

    Compact the current conversation into a handoff document for another agent to pick up.

    Also in 3 projects that use this

The file

Show its rules and text

We split this skill into the rules it gives an agent

23 rules. 0 are common, 18 are distinctive, and 5 are very specific to this project.

  • 0

    Common

    Most of the 23 edited versions we read keep these.

  • 18

    Distinctive

    This author's own choices. Worth a look.

  • 5

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  • could be automatic: a setting could enforce it
  1. Distinctive:

    Before changing anything, review your own work with a critical eye:

    line 12
  2. Distinctive:

    Run git diff to see all changes made this session

    line 14
  3. Distinctive:

    Check for wrong-approach errors: did you pick a strategy that's more complex than needed?

    line 15
  4. Distinctive:

    Check for misread-code errors: did you assume something about the existing codebase that isn't true?

    line 16
  5. Distinctive:

    Check for logic inversions: RTL/LTR swaps, off-by-one errors, flipped conditionals, wrong operator

    line 17
  6. Distinctive:

    Check for regressions: did you break something that was working before?

    line 18
  7. Distinctive:

    If you find problems, fix them now before proceeding.

    line 20
  8. Distinctive:

    Ensure callers appear before callees in each file (top-down organization)

    line 27
  9. Distinctive:

    Ensure consistent patterns with the existing codebase

    line 29
  10. Distinctive:

    Add new tests covering the new code where appropriate

    line 33
  11. Distinctive:

    Test docstrings must explain: why the test matters, what bug it prevents, what it covers

    line 34
  12. Distinctive:

    If neither exists, skip this step.

    line 42
  13. Very specific:

    Run make lint from the project root

    line 45
  14. Distinctive:

    Ensure critical paths and new code are covered by tests

    line 53
  15. Distinctive:

    If linting or tests fail, fix the issues and repeat steps 5-6

    line 56
  16. Distinctive:

    Only proceed when both commands succeed with zero errors

    line 58
  17. Very specific:

    Call advisor() on the finished change.

    line 64
  18. Distinctive:

    If the user opts to fix something, make the fix and re-run steps 5–6 (lint and test) before continuing.

    line 67
  19. Very specific:

    Create a git commit message with the bead ID parenthesized at the end of the first line, e.g.: Add report lineage fields (proj-d3j.2)

    line 95
  20. Distinctive:

    Check the bead's notes for design decisions and context that should inform the commit message

    line 96
  21. Distinctive:

    Ask the user for approval, then run git commit

    line 97
  22. Very specific:

    Only now, bd close <id> --suggest-next.

    line 98
  23. Very specific:

    Then ask the user: was that the session's last bead?: If it was, /close-shop is next.

    line 101

“Common” is measured: kept by at least 6 in 10 of the 23 edited versions of this file we could read. “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

Finalize work on an issue

Perform the following steps in order. Do not skip steps.

1. Self-Review

Before changing anything, review your own work with a critical eye:

  • Run git diff to see all changes made this session
  • Check for wrong-approach errors: did you pick a strategy that's more complex than needed? Is there a simpler, more standard way to achieve the same thing?
  • Check for misread-code errors: did you assume something about the existing codebase that isn't true? Verify key assumptions by re-reading the relevant code.
  • Check for logic inversions: RTL/LTR swaps, off-by-one errors, flipped conditionals, wrong operator
  • Check for regressions: did you break something that was working before?

If you find problems, fix them now before proceeding. Do not mention the self-review to the user unless you found and fixed something — then briefly note what you caught.

Then call advisor() for a transcript-aware second opinion — it sees your full session reasoning, so it catches wrong-approach and misread-code errors early, while changes are still small and cheap to undo. Surface any real findings to the user and fix what you both agree on before proceeding. (If no advisor tool is available in the session, say so once and go on.)

2. Refactor Session Code

  • Review all code changes made in the current session
  • Eliminate code duplication (DRY principle)
  • Ensure callers appear before callees in each file (top-down organization)
  • Fill in missing docstrings/comments -- focus on "why", not "what"; audience is senior devs
  • Ensure consistent patterns with the existing codebase
  • Do NOT make functional changes -- refactoring only

3. Add Tests

  • Add new tests covering the new code where appropriate
  • Test docstrings must explain: why the test matters, what bug it prevents, what it covers
  • Tests go in files mirroring source structure

4. User- and Project-Specific Steps

Extensions are read from two places, user first, then project, and both are followed:

  • ~/.claude/skill-extensions/finalize.md — the user's own conventions, the same in every project.
  • .claude/skill-extensions/finalize.md in the project — that project's: API type regeneration, doc updates, and the like.

If neither exists, skip this step.

5. Run Linting

  • Run make lint from the project root
  • Fix ALL linting errors and warnings
  • Minimize suppressing comments -- rewrite code to pass checks instead
  • Ensure consistent formatting

6. Run Tests

  • Run make test from the project root
  • Fix any failing tests
  • Ensure critical paths and new code are covered by tests

7. Iterate Until Stable

  • If linting or tests fail, fix the issues and repeat steps 5-6
  • Continue until both make lint and make test pass cleanly
  • Only proceed when both commands succeed with zero errors

8. Senior Review

With the change complete, lint-clean, and tests passing, get a senior review before committing:

  • Call advisor() on the finished change. It is transcript-aware: it knows your intent and what you tried, so it judges whether the whole change is sound.
  • Scale by change size. For a non-trivial diff, also spawn one fresh subagent (Explore or general-purpose) given only the diff and a one-line scope. Because it has none of your reasoning, it reads the code cold — an independent fresh-eyes pass that isn't anchored to how you narrated your own work. For a trivial diff, advisor() alone is enough.
  • Surface every finding to the user, each with your proposed response (fix / won't-fix / not-a-bug). The user decides what to act on — do not silently apply or dismiss findings.
  • If the user opts to fix something, make the fix and re-run steps 5–6 (lint and test) before continuing. Only proceed to close once gates pass again.

9. Close Issue

Close the bead last — after the commit is approved, not before. The neighbour check below can change what the commit message should say, and a commit the user declines or sends back for a fix must not leave a closed bead behind it.

  • Check which other beads this work changed. Closing your own bead is the easy half; the beads that quietly became done — or half-done — are the ones nobody looks at again. Cast a narrow net, scoped to this change: this is a task close, not the session-wide sweep /close-shop runs.

    • bd show <id> for what this bead hangs off, and bd list --parent=<parent> for its siblings if it has a parent.
    • bd search <keyword> on the files, subsystem, or symptom you just touched. An older bead filed against the same bug from a different angle is exactly what this catches and nothing else does. Then, per hit, one of:
    • Now also done — your change satisfies it. State the evidence and ask before closing; do not close someone else's bead on your own reading of the diff.
    • Partially done — bd update <id> --append-notes=... with what your change already covers and what is left, so the next agent does not redo the covered half.
    • Now wrong — its description assumes something your change made untrue. Correct the description.
    • Superseded — bd supersede <old> --with=<new>, not a silent close.

    A bead that is merely blocked or no longer wanted is not done: that is /defer's job, and closing to park destroys discoverability.

  • Create a git commit message with the bead ID parenthesized at the end of the first line, e.g.: Add report lineage fields (proj-d3j.2)
  • Check the bead's notes for design decisions and context that should inform the commit message
  • Ask the user for approval, then run git commit
  • Only now, bd close <id> --suggest-next. What --suggest-next prints is work that just became startable — next-work, not beads to re-verdict against the bullet above.
  • DO NOT run bd sync or git push
  • Then ask the user: was that the session's last bead? If it was, /close-shop is next. You cannot know the answer — the session may well continue — so ask rather than guess, and ask rather than stay silent: /close-shop is the only thing that ever re-reads the standing memories and the still-open beads, and it only helps if it gets typed.
  • Work on this bead is complete from the agent's perspective. Stop here.

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.