jrjsmrtn/project-orchestration-skills/setup-git-hooks

Claude Code and agent skill by jrjsmrtn/project-orchestration-skills

Trust tier 3
  • community
  • ext:[{"type":"hook","description":"Pre/post lifecycle hooks"}]
Source check pending

Checking that the SKILL.md file is still in the repository.

Configure two-stage git hooks (pre-commit + pre-push) for quality automation, with either pre-commit or lefthook as the hook manager. Use after bootstrap-project and setup-adrs, when adding quality gates to an existing project, or when standardizing quality automation.

Install

npx vskill@latest install jrjsmrtn/project-orchestration-skills/setup-git-hooks

Semi-extensibleMentions customization, but needs skill-specific knowledge. Read the extensible skills standard

SKILL.md

The same SKILL.md was published earlier as jrjsmrtn/project-orchestration-skills/setup-git-hooks.

Setup Git Hooks

Configure two-stage git hooks — fast checks on commit, thorough checks on push — using either pre-commit or lefthook as the hook manager.

When to Use

  • After running bootstrap-project and setup-adrs skills
  • When adding quality gates to an existing project
  • When standardizing quality automation across projects

Required Inputs

  1. Technology stack (Elixir, Python, TypeScript, etc.)
  2. Quality tools preference (can use defaults for each ecosystem)
  3. Multi-remote strategy (if using private + public remotes)

Two-Stage Strategy

Stage 1: Pre-commit (Fast, <30 seconds)

  • File hygiene (whitespace, line endings, merge conflicts)
  • Secret detection (critical security gate)
  • Code formatting check

Stage 2: Pre-push (Thorough, <3 minutes)

  • Linting with strict rules
  • Type checking
  • Security audit (dependencies)
  • Fast tests (exclude slow/integration)

Workflow

Step 0: Create Quality Configuration Reference

Before configuring tools, create the single source of truth: docs/reference/quality-configuration.md

markdown
# Quality Configuration
Single source of truth for all quality settings.
## Toolchain Versions
Three roles, and conflating them ships defects. Record all three even when two coincide today.
| Role | Version | Declared in | Meaning |
|------|---------|-------------|---------|
| **Floor** | [oldest supported] | [manifest] | the oldest a *consumer* needs — a compatibility claim |
| **Build** | [current] | [CI config] | what CI and releases are actually built with |
| **Inherited** | [if any] | [sub-module manifest] | a floor a dependency forces on you, not one you chose |
Per ecosystem, the floor lives in:
| Ecosystem | Floor | Build version |
|-----------|-------|---------------|
| Go | `go` directive in `go.mod` | `go-version:` in the workflow |
| Rust | `rust-version` (MSRV) in `Cargo.toml` | toolchain file / CI |
| Python | `requires-python` in `pyproject.toml` | `python-version:` in CI |
| Node | `engines.node` in `package.json` | `node-version:` in CI |
| Elixir | `elixir` requirement in `mix.exs` | CI matrix |
**Build with the current version, never the floor.** The floor states what a consumer needs;
building at it means building against the least-patched runtime. Released artifacts embed that
runtime — and if you publish an SBOM, they *record* it — so building at the floor can publish a
known-vulnerable runtime and document the fact in the accompanying BOM.
**Prove the floor separately.** One CI job builds and tests at exactly the declared floor, so the
compatibility claim is verified rather than aspirational. Do **not** run vulnerability scanning
there: an old toolchain has old advisories by definition, which is a reason not to *ship* it, not a
reason to stop supporting it.
**Record the per-call-site intent.** List every place a toolchain version is selected and why it
reads what it reads. A partial fix is the common failure — updating the two obvious workflows and
missing the scheduled scan.
**Record the maintenance obligation.** Pin the build *line* rather than tracking `latest`, so a new
major release cannot change what you ship without a commit; patch releases within the line still
arrive, which is how runtime security fixes reach you. Nothing automates the major bump — dependency
bots do not manage CI toolchain versions — so name it as a periodic, deliberate act. Its failure
mode is silent.
## Formatting Standards
| Setting | Value | Applies To |
|---------|-------|------------|
| Indent style | spaces | All files |
| Indent size | [2 or 4] | [Language-specific] |
| Line length | [80/100/120] | All code |
| End of line | lf | All files |
| Final newline | yes | All files |
| Trim trailing whitespace | yes | All files |
## Quality Checks by Stage
| Check | Pre-commit | Pre-push | CI | Notes |
|-------|------------|----------|-----|-------|
| Formatting | Yes | - | Yes | Auto-fix locally |
| Linting (fast) | Yes | - | Yes | Syntax, imports |
| Linting (slow) | - | Yes | Yes | Complex analysis |
| Type checking | - | Yes | Yes | Full type analysis |
| Unit tests | - | Yes | Yes | Fast tests locally |
| Integration tests | - | - | Yes | CI only |
| Security scanning | - | Yes | Yes | Secrets, deps |
| Coverage | - | - | Yes | CI only |
## Validation Checklist
Commands with expected output, not reminders — a reader or an agent should be able to run these
and compare. Substitute the ecosystem's own commands; the shape is what matters.

Every build-version selector in CI names the same pinned line (expect ONE distinct value):

grep -rhoE '(go|python|node|otp|elixir)-version:[[:space:]]*"?[^"[:space:]]+' .github/workflows/ \

Only the floor-compatibility job reads the floor from the manifest (expect exactly the jobs

listed in the per-call-site table above — nothing else):

grep -rn 'version-file' .github/workflows/

The floor still builds and tests (Go shown; use the ecosystem's pinning mechanism):

GOTOOLCHAIN=go[FLOOR] go build ./... && GOTOOLCHAIN=go[FLOOR] go test ./...

Vulnerability scanning is clean ON THE BUILD VERSION, not the floor:

[govulncheck ./... | pip-audit | cargo audit | mix deps.audit]

Local hooks and CI run the same commands (expect the same tool invocations on both sides):

grep -oE '(gofmt|go vet|go test|ruff|mix format|cargo fmt)[^"]' .lefthook.yml | sort -u grep -oE '(gofmt|go vet|go test|ruff|mix format|cargo fmt)[^"]' .github/workflows/ci.yml | sort -u

- [ ] `.editorconfig` matches Formatting Standards
- [ ] Linter configs match line length and indent
Pattern Reference: See CONSISTENT-QUALITY-GATES
Step 1: Create .editorconfig

Create .editorconfig matching the quality-configuration:

ini
root = true
[*]
indent_style = space
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
charset = utf-8
[*.{ex,exs,js,ts,jsx,tsx,yaml,yml,json,md}]
indent_size = 2
[*.py]
indent_size = 4
[*.{ex,exs,py,js,ts}]
max_line_length = 120
Step 2: Secret Detection Architecture

Secret detection works in three layers:

Layer 1: Global gitleaks config (~/.gitleaks.toml)

  • Infrastructure-specific patterns (hostnames, domains, private IPs, custom ports)
  • Allowlists for git-ignored files (CLAUDE.local.md, .envrc, vault files)
  • RFC 5737/7042 documentation addresses excluded from false positives

Layer 2: Project gitleaks config (.gitleaks.toml, .gitleaksignore)

  • Test fixture allowlists (generated keys, X.509 elements, mock data)
  • Documentation allowlists (demo credentials in tutorials)
  • Stop words for test data: test, example, sample, dummy, fake, mock, stub

Layer 3: Git hooks (pre-commit stage)

  • gitleaks protect --staged on every commit
  • Catches secrets before they enter git history

Create .gitleaks.toml if the project has test fixtures or documentation with intentional fake credentials:

toml
[extend]
useDefault = true
[allowlist]
description = "Project-specific allowlist for test data and documentation"
# Test fixtures with intentional fake data
paths = [
'''test/fixtures/.*''',
'''test/support/.*''',
]
# Stop words — values containing these are not secrets
stopwords = [
"test",
"example",
"sample",
"dummy",
"fake",
"mock",
]

Use .gitleaksignore for specific false positives that can't be handled by rules:

# Explain why each entry is not a real secret
path/to/file.ex:rule-id:line-number
Step 3: Sensitive Files in .gitignore

Ensure .gitignore covers all secret-bearing files:

# Secrets and credentials
.env
.env.*
!.env.example
.envrc
.envrc.local
*.pem
*.key
credentials.json
secrets.yaml
# Claude Code local files
CLAUDE.local.md

.envrc and .envrc.local (direnv) are treated like .env — they may contain or derive secrets (e.g., Keychain lookups). If a project needs a committed .envrc for non-secret PATH setup, use .envrc.local for the secret overrides and source it from .envrc:

bash
# .envrc (committed — no secrets)
PATH_add bin
source_env_if_exists .envrc.local
bash
# .envrc.local (git-ignored — secrets here)
export API_KEY="$(security find-internet-password -w -s example.com -a user 2>/dev/null)"

The list above is asserted, not just recommended: scripts/check-hygiene.sh (Step 5, Hygiene check) fails when a pattern is missing, and when .env.example is ignored because the !.env.example line is absent.

Step 4: Install Hook Framework

Preferred: lefthook (fast, no Python dependency, parallel execution):

bash
# macOS
port install lefthook # or: brew install lefthook
# Verify
lefthook version

Alternative: pre-commit (Python-based, wider ecosystem of third-party hooks):

bash
pipx install pre-commit
pre-commit --version
Step 5: Create Configuration

Create hook configuration based on framework choice and technology stack:

Dependency vulnerability auditing

The pre-push stage runs a dependency vulnerability audit per ecosystem — this satisfies the OpenSSF Scorecard Vulnerabilities check and the Best Practices Badge's dependency-vulnerability criterion. The tools are not interchangeable; know what each checks:

EcosystemToolChecksPrerequisite
Elixirmix deps.auditKnown CVEs in dependenciesadd {:mix_audit, "~> 2.1", only: [:dev, :test], runtime: false} to mix.exs
Elixirmix hex.auditRetired Hex packagesbuilt into Hex
Pythonpip-auditKnown CVEs (PyPI / OSV)pip install pip-audit (or uv)
Rustcargo auditRustSec advisory DBcargo install cargo-audit

For Elixir, run both: mix hex.audit flags retired/deprecated packages, while mix deps.audit (via the mix_audit package) flags packages with known CVEs — different failure modes, both needed. Elixir/BEAM advisories are increasingly issued by the Erlang Ecosystem Foundation, now a CVE Numbering Authority (CNA) for Hex.pm and the BEAM ecosystem under the EEF Ægis initiative — so mix deps.audit is only as good as the advisory feed it consumes, which the EEF now curates.

Lockfile and frozen installs

Commit the ecosystem lockfile and install from it deterministically — the OpenSSF Scorecard Pinned-Dependencies control, which makes builds reproducible and tamper-evident.

EcosystemLockfile (commit it)Frozen/locked install (CI + containers)
Python (uv)uv.lockuv sync --frozen
Elixirmix.lockmix deps.get --check-locked (CI)
RustCargo.lockcargo build --locked
Nodepackage-lock.jsonnpm ci

Ship the check as a pre-push and CI gate: the lockfile must be present and committed (present in the index — a lockfile that exists on disk but is git-ignored passes a plain ls), and it fails a manifest with no committed lock whatever its constraints say, which is stricter than flagging lower-bound (>= / ~>) constraints only: anyone installing without the lock resolves loosely. In a Containerfile, avoid COPY mix.lock* (optional glob): it silently masks a missing lockfile, and the check fails it.

Hygiene check — .gitignore and lockfiles

The script is `scripts/check-hygiene.sh`, in this skill's directory. Copy it into the project as scripts/check-hygiene.sh rather than retyping it, and run it from the repository root.

This is the start of the file. Read the full SKILL.md on GitHub.

Security

  • Security scanPassed, 95 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

Repository stars
15
7-day trend score
14

Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.

Extension points

  • hookPre/post lifecycle hooks

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/jrjsmrtn/project-orchestration-skills/setup-git-hooks/badge)](https://verified-skill.com/skills/jrjsmrtn/project-orchestration-skills/setup-git-hooks)

Something wrong with this skill or its page? Tell us.