setup-cdk-git
Use when setting up git workflows for Claude Code - installs pre-commit hooks, commit templates with Claude attribution, PR templates, branch naming helpers, and Claude-specific gitignore entries
What this skill does
# Setup CDK Git ## Overview Git workflow configuration optimized for Claude Code development. Installs hooks, templates, and conventions for consistent AI-assisted commits and PRs. ## When to Use - Setting up git workflows for Claude development - User asks about commit conventions or PR templates - Part of `setup-claude-dev-kit` bundle - User wants pre-commit hooks or Claude attribution ## Quick Reference | Component | Location | |-----------|----------| | Commit Template | `~/.gitmessage` | | Global Hooks | `~/.config/git/hooks/` | | Project Hooks | `.git/hooks/` or `.husky/` | | PR Template | `.github/pull_request_template.md` | | Gitignore | `~/.gitignore_global` | ## Installation Steps ### 1. Configure Git User (if needed) ```bash # Check if configured git config --global user.name || echo "Name not set" git config --global user.email || echo "Email not set" # Set if empty git config --global user.name "Your Name" git config --global user.email "[email protected]" ``` ### 2. Install Commit Message Template Create `~/.gitmessage`: ```bash cat > ~/.gitmessage << 'EOF' # <type>(<scope>): <subject> # # Types: feat, fix, docs, style, refactor, test, chore # Scope: component affected (optional) # Subject: imperative, no period, <50 chars # # Body: explain what and why (wrap at 72 chars) # # Footer: references, breaking changes, co-authors # # Co-Authored-By: Claude <[email protected]> EOF git config --global commit.template ~/.gitmessage ``` ### 3. Configure Global Gitignore Create `~/.gitignore_global`: ```bash cat > ~/.gitignore_global << 'EOF' # macOS .DS_Store .AppleDouble .LSOverride ._* # Editors *.swp *.swo *~ .idea/ .vscode/ *.sublime-* # Claude artifacts .claude/memory/ .claude-context/ *.claude-session # Environment files (safety) .env.local .env.*.local *.pem *.key EOF git config --global core.excludesfile ~/.gitignore_global ``` ### 4. Install Pre-commit Hook Framework **Option A: Simple bash hooks (no dependencies)** ```bash mkdir -p ~/.config/git/hooks cat > ~/.config/git/hooks/pre-commit << 'EOF' #!/bin/bash # CDK Pre-commit Hook # Check for debug statements if git diff --cached --name-only | xargs grep -l "console.log\|debugger\|print(" 2>/dev/null; then echo "Warning: Debug statements found. Continue? (y/n)" read -r response [[ "$response" != "y" ]] && exit 1 fi # Check for large files MAX_SIZE=5000000 # 5MB for file in $(git diff --cached --name-only); do if [ -f "$file" ]; then size=$(wc -c < "$file") if [ "$size" -gt "$MAX_SIZE" ]; then echo "Error: $file is larger than 5MB" exit 1 fi fi done exit 0 EOF chmod +x ~/.config/git/hooks/pre-commit git config --global core.hooksPath ~/.config/git/hooks ``` **Option B: Using Husky (for Node.js projects)** ```bash # In project directory npm install --save-dev husky npx husky init # Add hook echo 'npm test' > .husky/pre-commit ``` ### 5. Install Commit-msg Hook (Conventional Commits) ```bash cat > ~/.config/git/hooks/commit-msg << 'EOF' #!/bin/bash # Validate conventional commit format commit_regex='^(feat|fix|docs|style|refactor|test|chore|build|ci)(\(.+\))?: .{1,50}' if ! grep -qE "$commit_regex" "$1"; then echo "Error: Commit message doesn't follow conventional format." echo "Expected: <type>(<scope>): <subject>" echo "Types: feat, fix, docs, style, refactor, test, chore, build, ci" echo "" echo "Your message:" cat "$1" exit 1 fi EOF chmod +x ~/.config/git/hooks/commit-msg ``` ### 6. Create PR Template For GitHub, create `.github/pull_request_template.md`: ```markdown ## Summary <!-- Brief description of changes --> ## Changes - ## Test Plan - [ ] Unit tests pass - [ ] Manual testing completed - [ ] No regressions introduced ## Screenshots <!-- If applicable --> ## Checklist - [ ] Code follows project style - [ ] Self-reviewed my changes - [ ] Added/updated documentation - [ ] No secrets or credentials included --- Generated with Claude Code ``` ### 7. Configure Helpful Aliases ```bash git config --global alias.co checkout git config --global alias.br branch git config --global alias.ci commit git config --global alias.st status git config --global alias.unstage 'reset HEAD --' git config --global alias.last 'log -1 HEAD' git config --global alias.visual '!gitk' # Claude-friendly aliases git config --global alias.wip 'commit -am "wip: work in progress"' git config --global alias.undo 'reset --soft HEAD~1' git config --global alias.amend 'commit --amend --no-edit' ``` ### 8. Branch Naming Helper Add to shell config (`~/.zshrc` or `~/.bashrc`): ```bash # Branch naming helper newbranch() { local type=$1 local name=$2 local branch="${type}/${name}" if [[ -z "$type" || -z "$name" ]]; then echo "Usage: newbranch <type> <name>" echo "Types: feature, fix, docs, refactor, test" echo "Example: newbranch feature user-auth" return 1 fi git checkout -b "$branch" echo "Created and switched to: $branch" } ``` ## Verification ```bash # Check global config git config --global --list | grep -E "(template|excludes|hooks)" # Check commit template [ -f ~/.gitmessage ] && echo "Commit template installed" # Check hooks [ -x ~/.config/git/hooks/pre-commit ] && echo "Pre-commit hook installed" [ -x ~/.config/git/hooks/commit-msg ] && echo "Commit-msg hook installed" # Test conventional commit validation echo "bad commit" | git commit --dry-run -F - 2>&1 | grep -q "Error" && echo "Commit validation working" ``` ## Adaptation Mode When existing git setup detected: 1. **Backup configs:** ```bash mkdir -p ~/.claude-dev-kit/backups/$(date +%Y-%m-%d) cp ~/.gitconfig ~/.claude-dev-kit/backups/$(date +%Y-%m-%d)/gitconfig.bak 2>/dev/null cp ~/.gitmessage ~/.claude-dev-kit/backups/$(date +%Y-%m-%d)/gitmessage.bak 2>/dev/null ``` 2. **Check for conflicts:** - Existing commit template → Merge Claude attribution - Custom hooks path → Add CDK hooks alongside - Project-level .husky → Don't override with global hooks 3. **Merge, don't replace:** ```bash # Append Claude co-author to existing template echo "" >> ~/.gitmessage echo "# Co-Authored-By: Claude <[email protected]>" >> ~/.gitmessage ``` ## Common Issues | Issue | Fix | |-------|-----| | Hooks not running | Check `core.hooksPath` config and permissions | | Commit rejected | Verify message follows conventional format | | Template not showing | Ensure `commit.template` is set correctly | | Large file blocked | Use Git LFS or adjust hook threshold | | Husky conflicts | Choose either global hooks OR husky, not both | ## Updating ```bash # Re-run setup to update hooks # CDK updates hooks in place # For husky projects npm update husky ``` ## Hook Reference | Hook | Purpose | |------|---------| | pre-commit | Check for debug statements, large files | | commit-msg | Validate conventional commit format | | pre-push | (Optional) Run tests before push | ## Commit Types | Type | Use For | |------|---------| | feat | New feature | | fix | Bug fix | | docs | Documentation only | | style | Formatting, no code change | | refactor | Code change, no feature/fix | | test | Adding/updating tests | | chore | Build, deps, tooling | | build | Build system changes | | ci | CI configuration |
Related in AI Agents
skill-development
IncludedComprehensive meta-skill for creating, managing, validating, auditing, and distributing Claude Code skills and slash commands (unified in v2.1.3+). Provides skill templates, creation workflows, validation patterns, audit checklists, naming conventions, YAML frontmatter guidance, progressive disclosure examples, and best practices lookup. Use when creating new skills, validating existing skills, auditing skill quality, understanding skill architecture, needing skill templates, learning about YAML frontmatter requirements, progressive disclosure patterns, tool restrictions (allowed-tools), skill composition, skill naming conventions, troubleshooting skill activation issues, creating custom slash commands, configuring command frontmatter, using command arguments ($ARGUMENTS, $1, $2), bash execution in commands, file references in commands, command namespacing, plugin commands, MCP slash commands, Skill tool configuration, or deciding between skills vs slash commands. Delegates to docs-management skill for official documentation.
reprompter
IncludedTransform messy prompts into well-structured, effective prompts — single or multi-agent. Use when: "reprompt", "reprompt this", "clean up this prompt", "structure my prompt", rough text needing XML tags and best practices, "reprompter teams", "repromptception", "run with quality", "smart run", "smart agents", multi-agent tasks, audits, parallel work, anything going to agent teams. Don't use when: simple Q&A, pure chat, immediate execution-only tasks. See "Don't Use When" section for details. Outputs: Structured XML/Markdown prompt, quality score (before/after), optional team brief + per-agent sub-prompts, agent team output files. Success criteria: Single mode quality score ≥ 7/10; Repromptception per-agent prompt quality score 8+/10; all required sections present, actionable and specific.
adaptive-compaction
IncludedAdaptive add-on policy and recovery layer that decides WHEN to compact, prune, snapshot, or fork -- replacing fixed-percent auto-compaction across Claude Code, Codex, and MCP-capable hosts. Trigger on auto-compact timing or damage: "when should I compact", "is it safe to compact now or start a fresh session", "auto-compact fires too early/mid-task", "switching to an unrelated task but the window still has space", "context rot", "answers get worse the longer the session runs", "the agent forgot the plan or my decisions after it summarized", "add a layer on top that manages context without changing the agent", raising autoCompactWindow to give the policy room, or installing/tuning a cross-tool compaction policy or PreCompact hook -- even when "compaction" is never said but the problem is context-window pressure or post-summarization memory loss. Do NOT use to summarize a conversation, build RAG, write a summarization prompt (decides WHEN not HOW), or answer max-context-length trivia.
agent-skill-creator
IncludedCreate cross-platform agent skills from workflow descriptions. Activates when users ask to create an agent, automate a repetitive workflow, create a custom skill, or need advanced agent creation. Triggers on phrases like create agent for, automate workflow, create skill for, every day I have to, daily I need to, turn process into agent, need to automate, create a cross-platform skill, validate this skill, export this skill, migrate this skill. Supports single skills, multi-agent suites, transcript processing, template-based creation, interactive configuration, cross-platform export, and spec validation.
llm-wiki
IncludedUse when building or maintaining a persistent personal knowledge base (second brain) in Obsidian where an LLM incrementally ingests sources, updates entity/concept pages, maintains cross-references, and keeps a synthesis current. Triggers include "second brain", "Obsidian wiki", "personal knowledge management", "ingest this paper/article/book", "build a research wiki", "compound knowledge", "Memex", or whenever the user wants knowledge to accumulate across sessions instead of being re-derived by RAG on every query.
skill-master
IncludedAgent Skills authoring, evaluation, and optimization. Create, edit, validate, benchmark, and improve skills following the agentskills.io specification. Use when designing SKILL.md files, structuring skill folders (references, scripts, assets), ingesting external documentation into skills, running trigger evals, benchmarking skill quality, optimizing descriptions, or performing blind A/B comparisons. Keywords: agentskills.io, SKILL.md, skill authoring, eval, benchmark, trigger optimization.