Finalize
What I'll do
Run the full completion pipeline: lint → test → clean up → commit → PR. Ensures nothing ships without passing quality gates and nothing is left behind.
Inputs I'll use (ask only if missing)
- What was implemented (feature name or branch)
- Target branch for PR (default: main)
- Any files to exclude from commit (.env, credentials, large binaries)
How I'll think about this
1. SCAN — Detect what needs finalizing
git status # uncommitted changes
git worktree list # orphaned worktrees
git branch --no-merged main # unmerged feature branches
find . -name "*.orig" -o -name "*.bak" # temp files
ls .worktrees/ 2>/dev/null # stale worktree dirs
Report what was found before proceeding.
2. LINT — Run language-appropriate linters
| Stack | Command |
|---|---|
| Java / Maven | mvn checkstyle:check spotbugs:check -q |
| Java / Gradle | ./gradlew checkstyleMain spotbugsMain |
| React / TypeScript | npx eslint . --ext .ts,.tsx && npx tsc --noEmit |
| Flutter / Dart | dart analyze && dart format --set-exit-if-changed . |
| Android / Kotlin | ./gradlew ktlintCheck detekt |
| AngularJS | npx eslint . --ext .js |
Show actual linter output. If lint fails:
- Auto-fix what can be auto-fixed (
eslint --fix,dart format) - Surface remaining issues and fix them
- Re-run to confirm clean
3. TEST — Run test suites
| Stack | Command |
|---|---|
| Java / Maven | mvn test -q |
| Java / Gradle | ./gradlew test |
| React / Vitest | npx vitest run |
| Flutter | flutter test |
| Android | ./gradlew testDebugUnitTest |
| Playwright | npx playwright test |
Show actual test output with pass/fail counts. If tests fail → fix and re-run. Do NOT proceed with failing tests.
4. CLEAN — Remove debris
# Worktree cleanup
git worktree prune
rm -rf .worktrees/ 2>/dev/null
# Stale branches (only merged ones)
git branch --merged main | grep -v main | grep -v '\*' | xargs -r git branch -d
# Temp files
find . -name "*.orig" -name "*.bak" -name ".DS_Store" -delete 2>/dev/null
rm -f e2e/.captures.json 2>/dev/null
# Build artifacts (don't commit these)
# Check .gitignore covers: node_modules, target, build, .gradle, .dart_tool
5. STAGE — Selective git add
# Stage specific files — NEVER git add -A blindly
# Exclude: .env, credentials, secrets, large binaries, build dirs
git add <specific files and directories>
# Review what's staged
git diff --cached --stat
Show the staged file list to user for confirmation.
6. COMMIT — Conventional commit
git commit -m "<type>(<scope>): <description>"
- Derive type from changes: feat, fix, refactor, test, docs, chore
- Derive scope from primary directory changed
- Description from the feature/task name
7. PR — Create pull request
gh pr create --title "<title>" --body "$(cat <<'EOF'
## Summary
<bullet points of what changed>
## Test Results
<paste actual test output summary>
## Checklist
- [ ] Lint: clean
- [ ] Tests: all passing
- [ ] No orphaned worktrees or temp files
- [ ] No secrets or credentials in diff
EOF
)"
Return the PR URL.
Anti-patterns to flag
- ⚠️ Committing with failing tests
- ⚠️
git add -Awithout reviewing what's staged - ⚠️ Committing .env, credentials, or secrets
- ⚠️ Leaving orphaned worktrees or feature branches
- ⚠️ Empty commit messages or non-conventional format
- ⚠️ Skipping lint because "it's just a small change"
Quality bar
- ✅ Zero lint errors on committed code
- ✅ All tests pass with actual output shown
- ✅ No orphaned worktrees or stale branches remain
- ✅ No temp files, build artifacts, or secrets in the commit
- ✅ PR created with summary and test evidence
- ✅ Conventional commit message with correct type and scope
Workflow context
- Follows:
/spec-to-impl,/verify-impl, or any manual implementation work - Feeds into:
/pr-review(PR is ready for review) - Related:
/release-notes(PR description feeds release notes)
Output contract
produces:
- type: git_commit
ref: "<commit SHA>"
- type: pull_request
url: "<PR URL>"
branch: "<branch name>"
- type: evidence
lint_output: "<actual linter stdout>"
test_output: "<actual test runner stdout>"
files_committed: ["<list>"]
