Initial commit

This commit is contained in:
Zhongwei Li
2025-11-30 08:42:05 +08:00
commit 2a050efe7f
17 changed files with 1342 additions and 0 deletions

54
commands/checkpoint.md Normal file
View File

@@ -0,0 +1,54 @@
---
description: Create a quick WIP checkpoint commit to save your current work
model: claude-haiku-4-5-20251001
allowed-tools: Bash(git add:*), Bash(git commit:*), mcp__plugin_git_git-intelligence__get_diff_summary
argument-hint: [description]
---
# Quick Checkpoint Commit
Create a quick WIP checkpoint commit to save your current work.
## Instructions
Create a quick checkpoint commit to save work-in-progress. This is useful for:
- Saving state before risky operations
- Creating restore points during development
- Quick saves when switching context
### Workflow
1. **Check current status** - Use `get_status` MCP tool
- Quickly see staged, modified, and untracked files
- Check for any files that shouldn't be committed (secrets, etc.)
2. **Stage all changes** (unless there are files with secrets):
```bash
git add -A
```
3. **Create checkpoint commit**:
```bash
git commit -m "$(cat <<'EOF'
chore(wip): checkpoint - <brief description>
Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
EOF
)"
```
### Notes
- Checkpoints can be squashed later with `git rebase -i`
- The description should be brief (e.g., "before refactor", "auth working", "halfway done")
- Skip files that shouldn't be committed (secrets, large binaries)
### Arguments
If the user provides a description after the command, use it:
- `/git:checkpoint before api changes` -> `chore(wip): checkpoint - before api changes`
- `/git:checkpoint` -> Ask for a brief description or use current context
Now create a checkpoint commit.

122
commands/commit.md Normal file
View File

@@ -0,0 +1,122 @@
---
description: Create well-formatted commits using Conventional Commits specification
model: claude-sonnet-4-5-20250929
allowed-tools: Bash(git add:*), Bash(git commit:*), mcp__plugin_git_git-intelligence__get_recent_commits, mcp__plugin_git_git-intelligence__get_diff_summary
---
# Smart Commit
Create well-formatted commits using Conventional Commits specification.
## Instructions
You are a git commit specialist. Create atomic, well-documented commits following these rules:
### Commit Format
```
<type>(<scope>): <subject>
```
### Types (REQUIRED - use exactly these)
| Type | Description |
|------|-------------|
| feat | A new feature |
| fix | A bug fix |
| docs | Documentation changes |
| style | Code style changes (formatting, etc) |
| refactor | Code refactoring |
| perf | Performance improvements |
| test | Adding or updating tests |
| build | Build system changes |
| ci | CI/CD configuration changes |
| chore | Maintenance tasks |
| revert | Revert changes |
### Rules
- Subject line max 100 characters
- Use lowercase for type and scope
- No period at end of subject
- Scope should describe the area of change (e.g., auth, api, config)
- Subject should be imperative ("add" not "added", "fix" not "fixed")
### Workflow
1. **Check status and diff** (use MCP tools for efficiency):
- Use `get_status` tool to see all changes (staged, modified, untracked)
- Use `get_diff_summary` tool to review what will be committed
- Use `get_recent_commits` tool with `limit: 5` to see recent commit style
- For detailed diff content, use Bash: `git diff` or `git diff --cached`
2. **Analyze the changes**:
- Determine if changes should be one commit or split into multiple
- Identify the primary type of change (feat, fix, refactor, etc.)
- Identify the scope (which area of the codebase)
3. **Stage files** (if not already staged):
- Use `git add <files>` for specific files
- NEVER use `git add .` without reviewing what will be added
- Skip files that contain secrets (.env, credentials, etc.)
4. **Create the commit**:
```bash
git commit -m "$(cat <<'EOF'
<type>(<scope>): <subject>
[optional body explaining what and why]
Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
EOF
)"
```
5. **Handle pre-commit hook failures**:
- If hooks modify files, stage the changes and amend: `git add . && git commit --amend --no-edit`
- Only amend if: (1) you're the author, (2) commit not pushed
- Check authorship: `git log -1 --format='%an %ae'`
### Examples
**Feature commit:**
```
feat(auth): add OAuth2 login support
Implement OAuth2 flow with Google and GitHub providers.
Includes token refresh and session management.
Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
```
**Bug fix commit:**
```
fix(api): handle null response in user endpoint
The /api/users endpoint was crashing when the database
returned null for deleted users.
Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
```
**Chore commit:**
```
chore(deps): update dependencies to latest versions
Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
```
### Important Notes
- NEVER skip hooks with --no-verify unless explicitly asked
- NEVER force push to main/master
- NEVER commit files containing secrets
- If changes are too large, suggest splitting into multiple commits
- Ask user before committing if anything is unclear
Now analyze the current changes and create an appropriate commit.

152
commands/create-pr.md Normal file
View File

@@ -0,0 +1,152 @@
---
description: Create pull requests using GitHub CLI with Conventional Commits format
model: claude-sonnet-4-5-20250929
allowed-tools: Bash(git push:*), Bash(gh pr:*), mcp__plugin_git_git-intelligence__get_recent_commits, mcp__plugin_git_git-intelligence__get_diff_summary
---
# Create Pull Request
Create well-formatted pull requests using GitHub CLI with Conventional Commits specification.
## Prerequisites
Check if `gh` is installed and authenticated:
```bash
gh auth status
```
If not installed:
```bash
brew install gh
gh auth login
```
## Workflow
### 1. Gather Context
Use MCP tools for efficient data gathering:
- **Status** - Use `get_status` MCP tool
- **Recent commits** - Use `get_recent_commits` MCP tool
- **Diff summary** - Use `get_diff_summary` MCP tool
For branch info and comparison, use Bash:
```bash
# Check current branch
git branch --show-current
# Check if we need to push
git log --oneline @{u}..HEAD 2>/dev/null || echo "No upstream"
# All commits on this branch vs main
git log --oneline main..HEAD
```
### 2. Analyze Changes
Review all commits that will be in the PR (not just the latest):
```bash
git diff main...HEAD --stat
```
### 3. Determine PR Title
Use Conventional Commits format matching the primary change type:
| Type | Example |
|------|---------|
| feat | `feat(auth): add OAuth2 login support` |
| fix | `fix(api): handle null response` |
| docs | `docs(readme): update installation guide` |
| style | `style(ui): improve button styling` |
| refactor | `refactor(core): simplify data flow` |
| perf | `perf(queries): optimize database calls` |
| test | `test(auth): add login integration tests` |
| build | `build(deps): upgrade to Node 20` |
| ci | `ci(actions): add deployment workflow` |
| chore | `chore(deps): update dependencies` |
### 4. Create the PR
```bash
# Push branch if needed
git push -u origin HEAD
# Create PR with HEREDOC for body
gh pr create --title "<type>(<scope>): <subject>" --body "$(cat <<'EOF'
## Summary
<1-3 bullet points describing what this PR does>
## Changes
<Brief description of the changes made>
## Test Plan
- [ ] <Testing checklist item>
- [ ] <Another testing item>
---
Generated with [Claude Code](https://claude.ai/code)
EOF
)"
```
### 5. Draft vs Ready
- Use `--draft` flag if work is in progress
- Convert to ready: `gh pr ready`
## PR Body Template
```markdown
## Summary
- <Primary change/feature>
- <Secondary change if applicable>
## Changes
<Describe what changed and why>
## Test Plan
- [ ] Unit tests pass
- [ ] Manual testing completed
- [ ] No regressions
---
Generated with [Claude Code](https://claude.ai/code)
```
## Useful Commands
```bash
# List your open PRs
gh pr list --author "@me"
# Check PR status
gh pr status
# View specific PR
gh pr view <PR-NUMBER>
# Add reviewers
gh pr edit <PR-NUMBER> --add-reviewer username
# Merge PR (squash)
gh pr merge <PR-NUMBER> --squash
```
## Important Notes
- NEVER force push to main/master
- Always analyze ALL commits in the branch, not just the latest
- If there's a PR template at `.github/pull_request_template.md`, use it
- Return the PR URL when done so user can access it
Now analyze the current branch and create an appropriate PR.

62
commands/history.md Normal file
View File

@@ -0,0 +1,62 @@
---
description: Explore git commit history using git-intelligence MCP tools
model: claude-haiku-4-5-20251001
allowed-tools: mcp__plugin_git_git-intelligence__get_recent_commits, mcp__plugin_git_git-intelligence__search_commits, mcp__plugin_git_git-intelligence__get_diff_summary
argument-hint: [search-query]
---
# Git History Explorer
Interactively explore git commit history using the git-intelligence MCP tools.
## Instructions
Help the user explore git history to understand past changes. Use the MCP tools for efficient queries.
### Available MCP Tools
Based on the user's request, use the appropriate tool:
1. **Recent commits** → Use `get_recent_commits` tool
- Default: 10 commits, adjust `limit` as needed
2. **Search by message** → Use `search_commits` tool
- Set `query` to the search term
- Set `search_code: false` (default)
3. **Search by code change** → Use `search_commits` tool
- Set `query` to the code snippet
- Set `search_code: true` (like git log -S)
4. **Current status** → Use `get_status` tool
- Shows branch, staged/modified/untracked files
### Fallback to Bash
For queries not covered by MCP tools, use Bash:
- **File history**: `git log --oneline -10 -- <filepath>`
- **Branch info**: `git branch -a`
- **Show specific commit**: `git show <commit-hash> --stat`
- **Compare branches**: `git log --oneline main..HEAD`
- **Who changed what**: `git blame <filepath>`
- **Time-based queries**: `git log --oneline --since="last week"`
### Arguments
Parse the user's query to determine intent:
- `/git:history` → Use `get_recent_commits`
- `/git:history auth` → Use `search_commits` with query "auth"
- `/git:history src/api.ts` → Use Bash: `git log --oneline -10 -- src/api.ts`
- `/git:history -S function` → Use `search_commits` with search_code: true
- `/git:history last week` → Use Bash: `git log --oneline --since="last week"`
### Output
Present results clearly with:
- Commit hash (short)
- Subject line
- Author and relative time
- Optionally show diff for specific commits
Now explore the history based on the query: $ARGUMENTS

56
commands/session-log.md Normal file
View File

@@ -0,0 +1,56 @@
---
description: Show git activity during this Claude session
model: claude-haiku-4-5-20251001
allowed-tools: mcp__plugin_git_git-intelligence__get_recent_commits, mcp__plugin_git_git-intelligence__get_diff_summary
---
# Session Activity Log
Show what git activity has happened during this session using the git-intelligence MCP tools.
## Instructions
Display a summary of git activity during the current Claude session, including:
- Commits made
- Files changed
- Current uncommitted work
### Workflow
1. **Get recent commits** → Use `get_recent_commits` tool with `limit: 10`
- Shows commits with hash, message, author, and relative time
2. **Get current status** → Use `get_status` tool
- Returns branch, staged/modified/untracked counts, and file lists
3. **Get diff summary** → Use `get_diff_summary` tool
- Returns files changed with lines added/deleted
4. **Check for session summary file** (Bash fallback):
```bash
cat .claude-session-summary 2>/dev/null || echo "No session summary found"
```
### Output Format
Present the information in a clear summary:
```
## Session Activity
### Commits Made (recent)
- abc1234 feat(auth): add login endpoint (5 minutes ago)
- def5678 fix(api): handle null case (20 minutes ago)
### Current Changes
Staged: 2 files (+45, -12)
Modified: 3 files
Untracked: 1 file
### Uncommitted Files
M src/auth.ts
M src/api.ts
?? src/new-file.ts
```
Now show the session activity.