一键导入
finish
End-of-session routine. Ensures test coverage, performs self-review, runs validation, and commits cleanly. Use when finishing a unit of work.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
End-of-session routine. Ensures test coverage, performs self-review, runs validation, and commits cleanly. Use when finishing a unit of work.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Full feature implementation workflow with explore, plan, code, test, validate, and commit phases. Use for new features, enhancements, or significant code changes.
Iterate on an open PR until CI passes and all review feedback is addressed. Fetches status, categorizes findings by severity, applies fixes, and loops until clean.
Create a detailed implementation plan without writing code. Read-only analysis and planning with user approval gate. Use before implementing features or making significant changes.
Systematic security audit with confidence-based reporting. Analyzes attack surfaces, checks against OWASP categories, and reports only confirmed or likely vulnerabilities. Use for pre-merge security review or periodic audits.
Run validation checks to ensure code quality, security, and correctness. Supports quick (scoped), full (CI pipeline), fix (auto-correct), and CI mirror modes.
Systematic WCAG 2.1 AA accessibility audit with confidence-based reporting. Scans UI components for keyboard, screen reader, and visual accessibility issues. Use for pre-release audits or after major UI changes.
| name | finish |
| description | End-of-session routine. Ensures test coverage, performs self-review, runs validation, and commits cleanly. Use when finishing a unit of work. |
| category | process |
| triggers | ["done for now","wrap up","end of session","finishing up"] |
Purpose: Systematically conclude a unit of work — test, review, validate, commit Usage:
/finish
any types without documenting as todoNote: Command examples use
npmas default. Adapt to the project's package manager perai-assistant-protocol— Project Commands.
This skill performs lightweight end-of-session versions of these workflows:
/test-coverage — Phase 2 (test coverage check)/review — Phase 3 (self-review)/validate — Phase 4 (quality validation, runs after review fixes)/commit — Phase 6 (commit changes)/adr + /add-todo — Phase 8 (close completed todos)For more thorough execution of any phase, use the individual skill.
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
If no uncommitted changes and no commits ahead of base branch: Report "Nothing to finish — working tree is clean and branch is up to date" and exit.
Decision: If uncommitted changes exist, run full workflow. If only commits, skip to Phase 3 (Review).
Ensure changed code has test coverage.
Identify changed files:
git diff --name-only $MAIN..HEAD
git diff --name-only
Check for missing tests: Each changed .ts file should have a .spec.ts
Create missing tests with Gherkin test plans. If a test cannot be created (e.g., no testing framework configured, untestable code pattern, missing test utilities), report this to the user with the reason rather than silently skipping. Let the user decide whether to proceed without coverage for that file.
Run tests:
npm run test -- ChangedComponent
Fix failing tests: If any tests fail, investigate and fix the cause. Re-run to confirm the fix.
Phase 2 evidence:
### Test Coverage
- component.spec.ts — created, 4 tests passing
- utils.spec.ts — existing, 3 tests passing
- SKIPPED: config.ts — no testable exports (reported to user)
Exit criteria: All changed code has tests (or gaps reported to user), all tests pass.
Self-review before validation. Fixes made here will be validated in Phase 4.
Get the diff:
git diff HEAD
git diff --staged
Review checklist:
any typesconsole.log statementsany type handling: If any types are found, fix them with proper types before proceeding. Common replacements:
any -> unknown for truly unknown types (e.g., error handlers, generic middleware)any -> specific interface/type for known shapes (e.g., API responses, props)any -> generic type parameter (<T>) for reusable utilitiesany type genuinely cannot be replaced (rare — e.g., third-party library constraint), document it as a todo with /add-todo and add a // TODO: comment explaining whySecurity checklist:
eval(), innerHTML, or dangerouslySetInnerHTML with unsanitized inputchild_process.exec() with user-controlled inputrejectUnauthorized: false)Note issues by severity:
any types)Fix all critical issues before proceeding to validation.
Phase 3 evidence:
### Review
- Found 2 `any` types — fixed (UserProfile.tsx, formatUser.ts)
- No security issues
- No console.log statements
- 0 critical issues remaining
Exit criteria: No critical issues. Warnings documented if deferred.
Run checks in order — stop and fix if any fail. This phase runs AFTER review to ensure review fixes have not introduced new issues.
npm run typecheck
npm run lint
npm run test -- "path/to/changed/"
Re-validation loop: If any check fails, fix the issue and re-run all validation checks from the beginning. Maximum 3 iterations. If validation still fails after 3 iterations, report the remaining failures to the user and ask how to proceed.
Phase 4 evidence:
### Validation
- Typecheck: PASSED (0 errors)
- Lint: PASSED (0 warnings)
- Scoped tests: 10/10 passing
- Iterations: 1 (passed on first run)
Exit criteria: All checks pass.
Prompt whether documentation is needed:
ai — Update AI contextuser — User documentationreadme — READMEskip — No documentationWait for response.
Requires explicit user confirmation.
Ready to commit with message:
\`\`\`
<type>: <concise description>
\`\`\`
**Confirm commit?** (yes / edit message / cancel)
Do NOT commit without explicit approval.
Present structured exit options (see references/finish-options.md for the full decision tree, post-merge verification, and session summary template).
If preparing to push:
git log -1 --stat
git status
Check for todos completed by the work in this session.
Scan for related todos:
ls .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:
/adr --from-todo <todo-file> if the work involved design decisions (chose between approaches, adopted a pattern, established a convention)Report closures:
### 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.
## Wrap Summary
### Work Assessed
- **Branch:** feature/my-feature
- **Files changed:** 5
### Test Coverage
- utility.spec.ts — created, 6 tests passing
- helper.spec.ts — existing, 3 tests passing
### Review
- Found 1 `any` type — fixed (utility.ts: `any` -> `UtilityResult`)
- No security issues
- 0 critical issues remaining
### Validation
- Typecheck: PASSED
- Lint: PASSED
- Scoped tests: 10/10 passing
- Iterations: 1
### 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)
| ID | Type | Prompt / Condition | Expected |
|---|---|---|---|
| FIN-T1 | Positive | "I'm done for now" | Skill triggers |
| FIN-T2 | Positive | "Wrap up this session" | Skill triggers |
| FIN-T3 | Positive | "Finishing up" | Skill triggers |
| FIN-T4 | Negative | "Commit my changes" | Does NOT trigger (→ /commit) |
| FIN-T5 | Negative | "Run the tests" | Does NOT trigger (→ /validate) |
| FIN-T6 | Negative | "Review the code" | Does NOT trigger (→ /review) |
| FIN-T7 | Boundary | "Done, commit and push" | Triggers (finish encompasses commit) |