CAP-037: Install & Git Hooks

Structured Data

Capability Metadata

FieldValue
IDCAP-037
Versionv1.11
DomainDeveloper Experience
StatusDocumented
TypeInstallation / Hook
RelatedCAP-036, CAP-038, CAP-040
Sourcescripts/install.sh
Hook.git/hooks/post-commit
Output.planning/patterns/sessions.jsonl

Configuration Reference

Controlled by: postCommitHook toggle in CAP-036

# Install with post-commit hook
skill-creator install

# Uninstall cleanly
skill-creator install --uninstall

# Preview what will change
skill-creator install --dry-run

Hook location: .git/hooks/post-commit (per-repo installation)

Idempotent: Running install multiple times is safe — the hook is only written once and includes a guard comment to detect re-installation.

Technical Specifications

Shell compatibility: POSIX sh — runs on bash, zsh, dash, ash without modification

Hook overhead: <50ms per commit — reads git log HEAD, appends one JSONL record, exits

Failure mode: Hook failure is non-blocking — commit proceeds even if the observation write fails (uses || true exit guard)

Record format: Appends to .planning/patterns/sessions.jsonl with commit hash, timestamp, and file list from git diff --name-only HEAD~1 HEAD

Overview

The Install & Git Hooks capability provides the automation backbone for GSD Skill Creator's "zero-cost" observation model. The core idea: every git commit is a natural boundary between units of work, and that boundary is the ideal moment to capture a session observation — without requiring the developer to remember to run a command or interrupt their flow.

The skill-creator install command writes a POSIX-compatible post-commit hook to .git/hooks/post-commit. After every commit, this hook fires silently in the background, reads the staged files from git log, and appends a structured observation record to .planning/patterns/sessions.jsonl. From the developer's perspective, nothing changes — commits work exactly as before. From the system's perspective, a rich stream of structured observations begins accumulating automatically.

The install script is idempotent: running it twice does not create duplicate hooks. The --uninstall flag cleanly removes the hook and any related artifacts. The --dry-run flag shows exactly what would change without writing anything — making it safe to run in unfamiliar repositories to understand the installation footprint before committing.

History

Before v1.11, session observation in GSD Skill Creator required a manual invocation: developers had to remember to run /sc:observe before ending a session, or the session's patterns would not be captured. In practice, this was forgotten often enough that many teams had sparse observation logs with long gaps — weeks of work with no recorded observations, followed by a cluster of records when someone remembered to run the command.

The post-commit hook was the solution to the human memory problem. By attaching observation at the git commit boundary — an action developers already perform consistently — the system eliminated the reliance on deliberate human action. The hook was designed to be POSIX shell (not bash-specific) to ensure it worked on every developer's machine, including those running Alpine Linux in containers, developers using dash as their default shell, and CI environments with minimal shell installations.

The idempotency requirement came from experience with prior tool installations that left teams with duplicate hooks and confusing behavior when the same installation command was run during onboarding by multiple team members. The v1.11 install script includes a unique marker comment at the top of the hook to detect existing installations and skip re-installation gracefully.

Key Concepts

For Students & Teachers

A "git hook" is a script that git runs automatically at certain moments — before or after certain git operations. The post-commit hook runs right after every git commit completes. GSD Skill Creator uses this moment to write down a record of what just happened: which files changed, what time it is, what the commit hash is.

"Idempotent" means you can run the same operation multiple times and get the same result. If you run skill-creator install five times, you still end up with exactly one hook installed — not five. This is important for team workflows where multiple developers might run the install command without coordinating.

"Zero-cost" observation means there is no extra step you have to remember. You commit your work as normal. The observation happens automatically in the background. You never have to think about it — the patterns are captured whether you remember or not.

Usage Examples

Example 1: Initial project setup

# One-time setup for a new project
cd my-project
skill-creator install

# Output:
# Installing GSD Skill Creator git hooks...
# Writing .git/hooks/post-commit... done
# Creating .planning/patterns/ directory... done
# Installation complete. Observations will be captured on each commit.

Example 2: Preview before installing (dry-run)

skill-creator install --dry-run

# Output:
# [dry-run] Would write: .git/hooks/post-commit
# [dry-run] Would create: .planning/patterns/ (if missing)
# [dry-run] No files will be modified (dry-run mode)

Example 3: Clean uninstall

skill-creator install --uninstall

# Output:
# Removing .git/hooks/post-commit... done
# Uninstall complete. Existing sessions.jsonl data is preserved.

Related Capabilities