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
+15
View File
@@ -4,6 +4,21 @@
This is a **chezmoi source directory** for managing dotfiles across multiple machines. Files here are SOURCE files that get templated and deployed to the home directory.
### AI Assistant Configuration
This repository manages configuration for both **Claude Code** (Anthropic's official CLI) and **OpenCode** (an enhanced fork). The configuration is symlinked and shared between both tools:
- **Global guidelines** live in `~/.config/opencode/AGENTS.md` - this file contains cross-platform development guidelines (shell usage, build management, code style, git practices)
- **Project-specific context** lives in this repository's `CLAUDE.md` - chezmoi-specific instructions and restrictions
- **Symlinking structure**: The `home/dot_claude/` directory creates symlinks that allow both tools to share the same configuration files (settings.json points to `claude-settings.json` at the repository root)
- **Custom commands**: Both tools share command definitions stored in `home/dot_claude/commands/` (e.g., `commit-staged.md`, `amend-commit.md`, `reword-commit.md`)
- **IMPORTANT**: When adding new command definitions to `home/dot_claude/commands/`, you MUST create corresponding symlinks in `home/dot_config/opencode/command/`
- Symlink pattern: `symlink_<command-name>.md``../../../dot_claude/commands/<command-name>.md`
- Example: `symlink_amend-commit.md` contains `../../../dot_claude/commands/amend-commit.md`
- This ensures both Claude Code and OpenCode can access the same command definitions
When working in this repository, you're reading both the global AGENTS.md (general development practices) and this CLAUDE.md (chezmoi-specific guidelines). Project-specific CLAUDE.md files in other repositories take precedence over global guidelines.
### Key Concepts
**Source vs Target Pattern:**
+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
@@ -0,0 +1 @@
../../../.claude/commands/amend-commit.md