From d3b2c2a0298d8c67cb5f416f83152857f42dc320 Mon Sep 17 00:00:00 2001 From: luciano <52437683+lmontanares@users.noreply.github.com> Date: Wed, 2 Jul 2025 11:36:54 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20Add=20Pre-commit=20Integration?= =?UTF-8?q?=20to=20/git=20Command=20(#46)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit feat: add pre-commit integration to /git command - Add --pre-commit flag with setup and management capabilities - Create pre-commit-patterns.yml with Python (uv) and Node (npm) support - Include hooks for linting, formatting, and security scanning - Add usage examples to command documentation 🤖 Generated with [Claude Code](https://claude.ai/code) Co-authored-by: Claude --- .claude/commands/git.md | 7 ++++ .../commands/shared/execution-patterns.yml | 1 + .../commands/shared/pre-commit-patterns.yml | 32 +++++++++++++++++++ COMMANDS.md | 3 ++ 4 files changed, 43 insertions(+) create mode 100644 .claude/commands/shared/pre-commit-patterns.yml diff --git a/.claude/commands/git.md b/.claude/commands/git.md index b5afdee..9ba8ae1 100644 --- a/.claude/commands/git.md +++ b/.claude/commands/git.md @@ -17,6 +17,9 @@ Examples: - `/git --commit "Add user profile API endpoint"` - Standard commit w/ message - `/git --pr --reviewers alice,bob --labels api,feature` - Create PR w/ reviewers - `/git --flow feature "payment-integration" --think` - Full feature workflow +- `/git --pre-commit` - Setup pre-commit framework and basic hooks +- `/git --commit "Fix validation logic" --pre-commit` - Commit with pre-commit validation +- `/git --pre-commit --security` - Setup with security hooks included Git operations: @@ -28,8 +31,12 @@ Git operations: - feature: Feature branch workflow | hotfix: Emergency fix workflow - release: Release branch workflow | gitflow: Full GitFlow model +**--pre-commit:** Setup and manage pre-commit hooks | Auto-install framework | Configure quality checks | Run hooks before commits + @include shared/execution-patterns.yml#Git_Integration_Patterns +@include shared/pre-commit-patterns.yml#Pre_Commit_Setup + @include shared/docs-patterns.yml#Standard_Notifications @include shared/universal-constants.yml#Standard_Messages_Templates \ No newline at end of file diff --git a/.claude/commands/shared/execution-patterns.yml b/.claude/commands/shared/execution-patterns.yml index 0bc2df0..0fa53ac 100644 --- a/.claude/commands/shared/execution-patterns.yml +++ b/.claude/commands/shared/execution-patterns.yml @@ -293,6 +293,7 @@ Git_Workflows: Before_Commit: - "git status → Verify intended files" - "git diff --staged → Review changes" + - "Run pre-commit hooks if configured" - "Run tests if available" - "Check for secrets/credentials" Before_Push: diff --git a/.claude/commands/shared/pre-commit-patterns.yml b/.claude/commands/shared/pre-commit-patterns.yml new file mode 100644 index 0000000..0fad2fa --- /dev/null +++ b/.claude/commands/shared/pre-commit-patterns.yml @@ -0,0 +1,32 @@ +# Pre-commit Patterns +# Simple pre-commit hook configuration and management + +```yaml +Pre_Commit_Setup: + Install_Python: "uv add --dev pre-commit && uv run pre-commit install" + Install_Node: "npm install --save-dev pre-commit && npx pre-commit install" + Config: ".pre-commit-config.yaml" + + Basic_Hooks: + - "trailing-whitespace" + - "end-of-file-fixer" + - "check-yaml" + - "check-json" + - "check-merge-conflict" + + Language_Hooks: + Python: ["black", "ruff", "isort"] + JavaScript: ["eslint", "prettier"] + TypeScript: ["eslint", "prettier"] + Node: ["eslint", "prettier", "npm-audit"] + + Security_Hooks: + - "detect-secrets" + - "bandit" + + Commands: + Run_All: "pre-commit run --all-files" + Test_Hooks: "pre-commit run --hook-stage manual" + Skip_Hooks: "git commit --no-verify" + Update: "pre-commit autoupdate" +``` \ No newline at end of file diff --git a/COMMANDS.md b/COMMANDS.md index b92a99e..cf04082 100644 --- a/COMMANDS.md +++ b/COMMANDS.md @@ -352,11 +352,14 @@ Professional Git operations with safety features. - `--checkpoint` - Create checkpoint - `--merge` - Smart merge - `--history` - History analysis +- `--pre-commit` - Setup and run pre-commit hooks **Examples:** ```bash /git --checkpoint "before refactor" # Safety checkpoint /git --commit --validate --test # Safe commit +/git --pre-commit # Setup pre-commit hooks +/git --commit --pre-commit # Commit with validation ``` ### 🎨 Design & Architecture Commands (1)