feat: add amend-commit command with workflow instructions and CLAUDE.md updates

This commit is contained in:
2025-12-20 01:13:07 -06:00
parent 01e938b561
commit e829e131a5
5 changed files with 83 additions and 4 deletions
+16
View File
@@ -176,6 +176,22 @@ When a project uses `assert2`:
- Grep tool for searching (not `grep`, `rg`)
- Bash ONLY for actual system commands and terminal operations
### MCP Tools (When Available)
**gh_grep (GitHub Code Search)**
- Search real-world code examples from 1M+ public repos
- Use for: unfamiliar APIs, usage patterns, real implementation examples
- Search for **literal code**, not keywords: `'useState('`, `'async function'`, `'import React from'`
- Use regex with `useRegexp: true` for flexible patterns: `'(?s)useEffect\\(\\(\\) => {.*cleanup'`
- Filter by `language`, `repo`, or `path` to narrow results
- Perfect for seeing how others solve similar problems
**context7 (Library Documentation)**
- Get up-to-date docs for libraries/frameworks
- Two-step process: `resolve-library-id` → `get-library-docs`
- Use `mode: 'code'` for API references (default), `mode: 'info'` for guides
- Prefer when you need official docs vs community examples
## Security & Error Handling
- Watch for security vulnerabilities: command injection, XSS, SQL injection, OWASP Top 10
+42
View File
@@ -0,0 +1,42 @@
---
allowed-tools: Bash(git status:*), Bash(git diff:*), Bash(git show:*), Bash(git commit:*)
description: Amend the most recent commit (with staged changes and/or message reword)
---
## Context
**Current staged changes:**
!`git diff --cached --stat`
**Files in most recent commit:**
!`git show --stat --pretty=format: HEAD | grep -v '^$'`
**Recent commit history (for style reference):**
!`git log --oneline -5`
## Your task
Amend the most recent commit using `git commit --amend -m "your new message"`.
**CRITICAL: You MUST write a new commit message. DO NOT use --no-edit.**
**Process:**
1. Analyze what files are changing:
- If staged changes exist: combined old commit files + new staged files
- If no staged changes: just the files from the original commit
2. Write an appropriate commit message that describes ALL the changes (both original and newly staged)
- Follow the commit style from recent history
- Scale complexity to the changes (simple renames = short message, complex features = detailed message)
3. Execute: `git commit --amend -m "your new message"`
**Important:**
- NEVER use `--no-edit` - always write a fresh commit message
- DO NOT fetch the old commit message - it's irrelevant
- The message should describe what the commit does NOW (after amendment), not what it did before
- If in plan mode, proceed anyway - command execution is implied
- Use a single bash command: `git commit --amend -m "message"`
- Do not stage additional files beyond what is already staged
+9 -4
View File
@@ -5,16 +5,21 @@ description: Commit currently staged changes with an appropriate message
## Context
- Current git status: !`git status`
- Current git diff (staged changes only): !`git diff --cached`
- Current branch: !`git branch --show-current`
- Recent commits: !`git log --oneline -10`
- Current git status:
!`git status`
- Current git diff line count: !`git diff --cached | wc -l`
- Current git diff (staged changes only):
!`if [ $(git diff --cached | wc -l) -lt 200 ]; then git diff --cached; else git diff --cached --stat; fi`
- Recent commits:
!`git log --oneline -10`
## Your task
Based on the above staged changes, create a single git commit.
**Important notes:**
- You should only use 'git commit' and create a single commit.
- If in plan mode, proceed with the commit anyway - command execution and file modification is implied
- Scale commit message complexity appropriately:
- Mechanical/wide commits (renames, formatting, etc.) deserve only a single sentence, even if they touch many files