fix: auto-save uncommitted implementation work (te-3tj, gt-pvx safety net)

This commit is contained in:
furiosa
2026-03-25 17:42:01 +00:00
committed by mrtip
parent 0d0ef10779
commit 084dbb86cc
8 changed files with 493 additions and 0 deletions

49
.claude/commands/done.md Normal file
View File

@@ -0,0 +1,49 @@
---
description: Signal work complete and submit to merge queue
allowed-tools: Bash(gt done:*), Bash(git status:*), Bash(git log:*), Bash(git add:*), Bash(git commit:*), Bash(git push:*), Bash(bd close:*)
argument-hint: [--status COMPLETED|ESCALATED|DEFERRED] [--pre-verified]
---
# Done — Submit Work to Merge Queue
Signal that your work is complete and ready for the merge queue.
Arguments: $ARGUMENTS
## Pre-flight Checks
Before running `gt done`, verify your work is ready:
```bash
git status # Must be clean (no uncommitted changes)
git log --oneline origin/main..HEAD # Must have at least 1 commit
```
If there are uncommitted changes, commit them first:
```bash
git add <files>
git commit -m "<type>: <description>"
```
## Execute
Run `gt done` with any provided arguments:
```bash
gt done $ARGUMENTS
```
**Common usage:**
- `gt done` — Submit completed work (default: --status COMPLETED)
- `gt done --pre-verified` — Submit with pre-verification (you ran gates after rebase)
- `gt done --status ESCALATED` — Signal blocker, skip MR
- `gt done --status DEFERRED` — Pause work, skip MR
**If the bead has nothing to implement** (already fixed, can't reproduce):
```bash
bd close <issue-id> --reason="no-changes: <brief explanation>"
gt done
```
This command pushes your branch, submits an MR to the merge queue, and transitions
you to IDLE. The Refinery handles the actual merge. You are done after this.

View File

@@ -0,0 +1,24 @@
---
description: Hand off to fresh session, work continues from hook
allowed-tools: Bash(gt handoff:*)
argument-hint: [message]
---
Hand off to a fresh session.
User's handoff message (if any): $ARGUMENTS
Execute these steps in order:
1. Ask the user: "Ready to hand off? This will restart the session. (y/N)"
- If the user says no or doesn't confirm, stop here. Do NOT run gt handoff.
- Only proceed if the user explicitly confirms with 'y' or 'yes'.
2. If user provided a message, run the handoff command with a subject and message:
`gt handoff -y -s "HANDOFF: Session cycling" -m "USER_MESSAGE_HERE"`
3. If no message was provided, run the handoff command:
`gt handoff -y`
Note: The new session will auto-prime via the SessionStart hook and find your handoff mail.
End watch. A new session takes over, picking up any molecule on the hook.

115
.claude/commands/review.md Normal file
View File

@@ -0,0 +1,115 @@
---
description: Review code changes with structured grading (A-F)
allowed-tools: Bash(git diff:*), Bash(git rev-parse:*), Bash(gh pr diff:*)
argument-hint: [--staged | --branch | --pr <url>]
---
Review code and provide a structured assessment with grading.
Arguments: $ARGUMENTS
## Diff Source Resolution
Determine the diff to review based on arguments:
| Argument | Diff command | Use case |
|----------|-------------|----------|
| (none) | `git diff` + `git diff --staged` | Review uncommitted + staged changes |
| `--staged` | `git diff --staged` | Review only staged changes |
| `--branch` | `git diff origin/<base>...HEAD` | Review branch diff vs base branch |
| `--pr <url>` | `gh pr diff <url>` | Review a GitHub PR |
### Step 1: Get the diff
Based on the arguments, run the appropriate diff command:
```bash
# Default (no args): uncommitted + staged
DIFF=$(git diff; git diff --staged)
# --staged: only staged
DIFF=$(git diff --staged)
# --branch: branch diff (detect base branch)
BASE=$(git rev-parse --abbrev-ref HEAD@{upstream} 2>/dev/null | sed 's|origin/||' || git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null | sed 's|refs/remotes/origin/||' || echo "main")
DIFF=$(git diff origin/$BASE...HEAD)
# --pr <url>: PR diff
DIFF=$(gh pr diff <url>)
```
If the diff is empty, report "No changes to review" and stop.
### Step 2: Review the diff
Review the diff systematically. For each issue found, classify by severity:
**CRITICAL** - Must fix before merge:
- Security vulnerabilities (injection, auth bypass, secrets in code)
- Data loss risks (missing transactions, unsafe deletes)
- Correctness bugs (race conditions, nil dereference, logic errors)
**MAJOR** - Should fix before merge:
- Logic errors that may not crash but produce wrong results
- Missing error handling on external calls
- API contract violations
- Missing tests for critical paths
**MINOR** - Nice to fix:
- Style inconsistencies with surrounding code
- Naming issues (unclear or misleading names)
- Missing comments on non-obvious logic
- Minor code smells
For each issue, note:
- File and line number
- Severity (CRITICAL, MAJOR, MINOR)
- Description of the issue
- Suggested fix (specific, actionable)
### Step 3: Assign grade
Grade is determined by the highest severity issue found:
| Grade | Criteria | Verdict |
|-------|----------|---------|
| **A** | No CRITICAL, MAJOR, or MINOR issues | PASS |
| **B** | MINOR issues only (no CRITICAL or MAJOR) | PASS |
| **C** | MAJOR issues present (no CRITICAL) | FAIL |
| **D** | CRITICAL issues present | FAIL |
| **F** | Unreviewable (empty diff, binary files, generated code only) | SKIP |
### Step 4: Output structured review
Output the review in this exact format:
```
Grade: <A|B|C|D|F>
CRITICAL (<count> issues)
<file>:<line> — <description>
Suggested fix: <actionable fix>
MAJOR (<count> issues)
<file>:<line> — <description>
Suggested fix: <actionable fix>
MINOR (<count> issues)
<file>:<line> — <description>
Suggested fix: <actionable fix>
Summary: <N> CRITICAL, <N> MAJOR, <N> MINOR
Verdict: <PASS|FAIL|SKIP>
```
Omit empty severity sections (e.g., if no CRITICAL issues, don't print the CRITICAL section).
If Grade is A, output:
```
Grade: A
No issues found.
Summary: 0 CRITICAL, 0 MAJOR, 0 MINOR
Verdict: PASS
```