Finish
Purpose: Systematically conclude a unit of work — test, validate, review, commit Usage:
/finish
Constraints
- •Never commit with failing tests
- •Never skip validation (minimum: type check + lint)
- •Never commit
anytypes without documenting as todo - •Never force push without explicit request
- •Never commit secrets
Note: Command examples use
npmas default. Adapt to the project's package manager perai-assistant-protocol— Project Commands.
Related Skills
This skill performs lightweight end-of-session versions of these workflows:
- •
/test-coverage— Phase 2 (test coverage check) - •
/validate— Phase 3 (quality validation) - •
/review— Phase 4 (self-review) - •
/commit— Phase 6 (commit changes) - •
/adr+/add-todo— Phase 8 (close completed todos)
For more thorough execution of any phase, use the individual skill.
Workflow
Phase 1: Assess Current State
MAIN=$(git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null | sed 's@^refs/remotes/origin/@@' || echo "main") git branch --show-current git status --short git log --oneline $MAIN..HEAD
Decision: If uncommitted changes exist, run full workflow. If only commits, skip to Phase 4 (Review).
Phase 2: Cover with Tests
Ensure changed code has test coverage.
- •
Identify changed files:
bashgit diff --name-only $MAIN..HEAD git diff --name-only
- •
Check for missing tests: Each changed
.tsfile should have a.spec.ts - •
Create missing tests with Gherkin test plans
- •
Run tests:
bashnpm run test -- ChangedComponent
Exit criteria: All changed code has tests, all tests pass.
Phase 3: Validate
Run checks in order — stop and fix if any fail:
npm run typecheck npm run lint npm run test -- "path/to/changed/"
Exit criteria: All checks pass.
Phase 4: Review
Self-review before committing:
- •
Get the diff:
bashgit diff HEAD git diff --staged
- •
Review checklist:
- • No
anytypes - • Proper TypeScript patterns
- • Tests have test plans
- • No
console.logstatements
- • No
- •
Security checklist:
- • No hardcoded secrets, API keys, or credentials
- • No
eval(),innerHTML, ordangerouslySetInnerHTMLwith unsanitized input - • No raw SQL with string interpolation
- • No
child_process.exec()with user-controlled input - • Input validation present at system boundaries
- • No disabled security controls (
rejectUnauthorized: false)
- •
Note issues by severity:
- •Critical — must fix before commit
- •Warning — should fix, document if deferred
- •Suggestion — nice to have
Exit criteria: No critical issues. Warnings documented if deferred.
Phase 5: Docs (Optional)
Prompt whether documentation is needed:
- •
ai— Update AI context - •
user— User documentation - •
readme— README - •
skip— No documentation
Wait for response.
Phase 6: Commit
Requires explicit user confirmation.
- •Stage changes
- •Review staged diff
- •Show commit preview and ask for confirmation
- •Only after "yes": commit
Ready to commit with message: \`\`\` <type>: <concise description> \`\`\` **Confirm commit?** (yes / edit message / cancel)
Do NOT commit without explicit approval.
Phase 7: Final Verification (Optional)
If preparing to push:
git log -1 --stat git status
Phase 8: Close Todos
Check for todos completed by the work in this session.
- •
Scan for related todos:
bashls .ai-project/todos/*.md 2>/dev/null
- •
For each open todo, compare its acceptance criteria and affected files against the committed changes. If all criteria are met:
- •Invoke
/adr --from-todo <todo-file>if the work involved design decisions (chose between approaches, adopted a pattern, established a convention) - •Skip the ADR if the work was purely mechanical
- •Delete the completed todo file
- •Stage and commit the ADR creation and todo deletion together
- •Invoke
- •
Report closures:
markdown### Todos Closed - `refactor-api-client.md` — closed, ADR created: `api-client-pattern.md` - `add-input-validation.md` — closed, no ADR needed
Skip this phase if no .ai-project/todos/ directory exists or no todos match the session's work.
Output Format
## Wrap Summary ### Work Assessed - **Branch:** feature/my-feature - **Files changed:** 5 ### Test Coverage - utility.spec.ts - created, 6 tests passing ### Validation - Type checking - passed - Linting - passed - Scoped tests - 10/10 passing ### Review - No critical issues ### Commit - Committed: `feat: add data export feature` - SHA: abc1234 ### Todos Closed - `refactor-api-client.md` — closed, ADR: `api-client-pattern.md` - (or: No todos matched this session's work)