precommit-workflow-management · git:20260905.a73d7ea · 2026-09-05 · sha256 8d0d13b770f79881

precommit-workflow-management git:20260905.a73d7eaA

Immutable. This exact content is served forever at /api/v1/blob/8d0d13b770f79881.

---
name: precommit-workflow-management
description: >-
  Rules, architecture, and runbooks for configuring, updating, and operating the intelligent Git pre-commit workflow.
---

# Pre-Commit Workflow Management Skill

This skill explains how to maintain, configure, and execute the intelligent pre-commit hook workflow across polyglot repositories.

---

## 1. Local Branch-First Development

> [!IMPORTANT]
> **CREATE A LOCAL BRANCH FIRST**: Always start by creating a dedicated local branch from `main`:
> ```bash
> git switch -c <developer-or-agent>/main/<feature-name>
> ```
> Never make changes directly on `main`.

---

## 2. Pre-Commit Architecture

The pre-commit workflow typically lives in `.githooks/pre-commit` and is tracked directly in version control.

```text
Staged Changes Detected (git diff --cached)
  │
  ├── Only Go files changed ───────► Run Go formatting, vet, tests, build
  ├── Only Python files changed ───► Run Pyright/Ruff, test suites
  ├── Only Frontend files changed ─► Run Biome/Linter, frontend build
  ├── Only Documentation changed ──► Fast-path bypass (<0.2s)
  └── Global / Config / Manual ────► Full monorepo validation gate
```

---

## 3. Key Features

1. **Selective Staged-File Execution**: Avoids unnecessary work by only running checks relevant to the files staged for the commit.
2. **Fast-Path for Documentation**: Commits containing only markdown (`*.md`), text (`*.txt`), or asset files skip expensive build and test pipelines.
3. **Subshell Directory Isolation**: Every check runs in a subshell `(cd "${REPO_ROOT}" && ...)` to prevent current working directory drift.
4. **Fail-Fast with Remediation**: Aborts immediately on failure and outputs exact commands needed to fix the problem.
5. **Zero External Runtime Dependencies**: Implemented in portable POSIX bash, requiring no heavy wrapper packages at the repository root.

---

## 4. Operations & Maintenance Runbook

### Activating the Hook Locally
```bash
make hooks-install
# Or: ./scripts/install-hooks.sh
```

### Manually Running Pre-Commit Gate
```bash
make pre-commit
```

### Bypass Flags (Emergency Only)
```bash
# Skip tests for quick drafts
SKIP_TESTS=1 git commit -s -S -m "chore: draft"

# Skip builds for lightweight edits
SKIP_BUILDS=1 git commit -s -S -m "fix: comment"

# Force full validation across all subsystems
PRECOMMIT_ALL=1 git commit -s -S -m "feat: core change"
```