Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
138 changes: 138 additions & 0 deletions .claude/commands/branch-cleanup.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
# Branch Cleanup Command

Clean up merged and stale branches both locally and remotely.

## Usage

```bash
/branch-cleanup
/branch-cleanup --remote
/branch-cleanup --dry-run
```

## What It Does

This command helps maintain a clean repository by identifying and removing:

### Local Branches

- **Merged Branches**: Branches already merged into main/master
- **Stale Branches**: Branches with no activity for 30+ days
- **Gone Remote Branches**: Local branches tracking deleted remote branches

### Remote Branches (with --remote)

- **Merged PR Branches**: Branches from merged pull requests
- **Stale Remote Branches**: No activity for 30+ days
- **Abandoned Branches**: No commits, PRs, or activity

### Protected Branches

Never deletes:

- main, master, develop
- Current branch
- Branches with unmerged changes
- Branches specified in protection list

## Example Output

```
🧹 Branch Cleanup
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

📍 Current branch: feat/add-commands
🔒 Protected: main, master, develop

📊 Analysis
• Total local branches: 15
• Merged branches: 8
• Stale branches (30+ days): 3
• Up-to-date branches: 4

🗑️ Branches to delete (11):

Merged (8):
✓ feat/227-commitlint (merged 2 days ago)
✓ feat/226-common-utils (merged 2 days ago)
✓ feat/225-docker-in-docker (merged 2 days ago)
... and 5 more

Stale (3):
⚠ experiment/new-feature (90 days old)
⚠ fix/old-bug (45 days old)
⚠ refactor/unused (60 days old)

Delete these branches? [y/N]: y

Deleting branches...
✓ Deleted feat/227-commitlint
✓ Deleted feat/226-common-utils
✓ Deleted feat/225-docker-in-docker
✓ Deleted 8 more branches

✨ Cleanup complete! Removed 11 branches.
```

## Options

```bash
# Preview without deleting (recommended first run)
/branch-cleanup --dry-run

# Include remote branches
/branch-cleanup --remote

# Auto-confirm deletion (for CI)
/branch-cleanup --yes

# Custom staleness threshold (default: 30 days)
/branch-cleanup --stale-days 60

# Only merged branches
/branch-cleanup --merged-only
```

## Safety Features

- **Dry Run**: Preview before deletion
- **Interactive Confirmation**: Requires user approval
- **Protection List**: Never deletes protected branches
- **Unmerged Detection**: Warns about unmerged changes
- **Current Branch**: Never deletes current branch

## CI Integration

```yaml
# .github/workflows/branch-cleanup.yml
- name: Cleanup Merged Branches
run: |
bash script/branch-cleanup.sh --merged-only --yes
```

## Staleness Criteria

| Age | Status | Action |
| ------ | ---------- | ------ |
| < 30d | Active | Keep |
| 30-60d | Stale | Warn |
| 60-90d | Very Stale | Delete |
| > 90d | Abandoned | Delete |

## Benefits

- 🧹 **Clean Repository**: Remove clutter
- ⚡ **Faster Operations**: Fewer branches to manage
- 👀 **Better Visibility**: Focus on active work
- 💾 **Disk Space**: Free up local storage
- 🔄 **Best Practice**: Regular maintenance habit

## Implementation

This command is implemented in `script/branch-cleanup.sh`.

## Requirements

- Git repository
- GitHub CLI (`gh`) for remote branch operations (optional)
- Proper permissions for remote deletions
123 changes: 123 additions & 0 deletions .claude/commands/dependency-health-check.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
# Dependency Health Check Command

Comprehensive dependency health analysis including updates, security, and licensing.

## Usage

```bash
/dependency-health-check
```

## What It Does

This command performs a comprehensive health check of all project dependencies:

### npm Dependencies

- **Outdated Packages**: Detects packages with available updates
- **Security Vulnerabilities**: Scans for known vulnerabilities (`npm audit`)
- **Deprecated Packages**: Identifies deprecated dependencies
- **License Compliance**: Checks for incompatible licenses
- **Peer Dependencies**: Validates peer dependency requirements

### DevContainer Features

- **Feature Updates**: Checks for newer versions of DevContainer features
- **Base Image**: Verifies if base image has updates
- **Deprecated Features**: Identifies deprecated features

### Analysis Report

- **Risk Level**: Critical, High, Medium, Low
- **Action Required**: Immediate, Soon, Optional
- **Recommendations**: Specific actions to improve dependency health

## Example Output

```
🔍 Dependency Health Check
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

📦 npm Packages (425 total)
✓ No critical vulnerabilities
⚠ 3 high severity vulnerabilities
• 12 packages can be updated
• 2 deprecated packages found

🔒 Security Status: Medium Risk
High: 3 vulnerabilities
- axios: Prototype pollution (CVE-2023-XXXX)
- semver: ReDoS vulnerability (CVE-2023-YYYY)
- json5: Prototype pollution (CVE-2022-ZZZZ)

📊 Update Summary
Major: 2 packages
Minor: 7 packages
Patch: 3 packages

⚠ Deprecated Packages
• request (use axios or node-fetch instead)
• babel-eslint (use @babel/eslint-parser)

✅ License Compliance
• All licenses compatible
• MIT: 387 packages
• Apache-2.0: 28 packages
• BSD-3-Clause: 10 packages

🏥 Overall Health: 75/100
Recommendations:
1. Update axios to v1.6.0 (security fix)
2. Replace deprecated packages
3. Update 12 minor/patch versions

Next steps:
npm update # Update minor/patch versions
npm audit fix # Auto-fix security issues
npm outdated # See all outdated packages
```

## Options

```bash
# JSON output for CI integration
/dependency-health-check --json

# Fail on high severity issues
/dependency-health-check --strict
```

## CI Integration

```yaml
# .github/workflows/dependency-health.yml
- name: Dependency Health Check
run: bash script/dependency-health-check.sh --strict
```

## Risk Levels

| Level | Criteria | Action |
| -------- | ---------------------------------- | --------- |
| Critical | Critical vulnerabilities | Immediate |
| High | High severity or many outdated | Soon |
| Medium | Some vulnerabilities or deprecated | Optional |
| Low | Minor updates only | Optional |

## Benefits

- 🛡️ **Security**: Early detection of vulnerabilities
- 📊 **Visibility**: Clear dependency status
- ⚡ **Proactive**: Catch issues before they're problems
- 📋 **Compliance**: License and policy enforcement
- 🔄 **Maintenance**: Easier dependency management

## Implementation

This command is implemented in `script/dependency-health-check.sh`.

## Requirements

- Node.js and npm
- Access to npm registry
- DevContainer configuration (optional)
Comment on lines +119 to +123

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Add jq to the requirements list.

The script depends on jq for JSON parsing, but it's not listed here.

 ## Requirements

 - Node.js and npm
+- jq (for JSON parsing)
 - Access to npm registry
 - DevContainer configuration (optional)
🤖 Prompt for AI Agents
In .claude/commands/dependency-health-check.md around lines 119 to 123, the
requirements list omits the jq dependency used by the script; update the
Requirements section to add "jq" (e.g., "jq (for JSON parsing)") so the document
accurately lists all runtime dependencies and users know to install jq before
running the script.

106 changes: 106 additions & 0 deletions .claude/commands/pre-pr-checklist.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
# Pre-PR Checklist Command

Automate comprehensive checks before creating a pull request.

## Usage

```bash
/pre-pr-checklist
```

## What It Does

This command runs a comprehensive checklist to ensure your changes are ready for pull request:

### Quality Checks (Sequential)

1. **Lint Check**: Runs ESLint to detect code issues
2. **Format Check**: Verifies Prettier formatting
3. **Type Check**: Validates TypeScript types (if applicable)
4. **Unit Tests**: Runs all tests with coverage
5. **Integration Tests**: Runs Bats integration tests
6. **Shellcheck**: Validates shell scripts

### PR Analysis

- **Size Estimation**: Calculates diff lines and file count
- **Size Label**: Suggests appropriate size label (S/M/L/XL)
- **Linked Issues**: Checks for related GitHub issues
- **Commit Messages**: Validates conventional commit format

### PR Preparation

- **Branch Status**: Checks if branch is up-to-date with main
- **Merge Conflicts**: Detects potential merge conflicts
- **Template Suggestion**: Recommends PR template content

## Size Thresholds

| Label | Line Changes | File Count |
| ------- | ------------ | ---------- |
| size/S | < 100 | < 10 |
| size/M | < 300 | < 20 |
| size/L | < 1000 | < 30 |
| size/XL | ≥ 1000 | ≥ 30 |

## Example Output

```
📋 Pre-PR Checklist
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

✅ Quality Checks
✓ Lint check passed
✓ Format check passed
✓ Tests passed (101/101)
✓ Coverage: 82.5% (threshold: 70%)

📊 PR Analysis
• Size: Medium (247 lines, 8 files)
• Suggested label: size/M
• Linked issues: #227
• Commits: 3 (all follow conventional commits)

🔄 Branch Status
✓ Up-to-date with main
✓ No merge conflicts

✨ Ready to create PR!
```

## Options

```bash
# Skip tests (faster, but not recommended)
/pre-pr-checklist --skip-tests

# Skip integration tests only
/pre-pr-checklist --skip-integration
```

## Implementation

This command is implemented in `script/pre-pr-checklist.sh`.

## Integration

Works seamlessly with:

- GitHub Actions CI workflows
- Git hooks (pre-push)
- IDE integrations
- Manual PR preparation

## Benefits

- 🚀 **Faster Reviews**: Catch issues before PR creation
- ✅ **Quality Assurance**: All checks pass before submission
- 📊 **Better PRs**: Proper sizing and documentation
- ⚡ **Time Saving**: One command instead of multiple

## Requirements

- Git repository
- Node.js and npm
- GitHub CLI (`gh`) for issue detection
- All project dependencies installed
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,6 @@
}
}
},
"postCreateCommand": "bash script/setup-env.sh && bash script/setup-mcp.sh && sudo chown -R vscode:vscode /workspaces/config && npm ci && npm run prepare && cp -r /tmp/.husky /workspaces/config/ && cp git/commitlint.config.js commitlint.config.js && /usr/local/bin/setup-claude.sh",
"postCreateCommand": "bash script/setup-env.sh && bash script/setup-mcp.sh && sudo chown -R vscode:vscode /workspaces/config && npm ci && npm run prepare && cp -r /tmp/.husky /workspaces/config/ && cp git/commitlint.config.js commitlint.config.js && bash script/sync-claude-commands.sh && /usr/local/bin/setup-claude.sh",
"runArgs": ["--env-file=${localEnv:HOME}/.devcontainer.env"]
}
Loading
Loading