commit-discipline

Validates git commit messages against a structured body schema with trailers and hooks.

4|Updated Jun 9, 2026
One-click install
npx skills add https://github.com/laicluse/agent-fieldkit --skill commit-discipline-laicluse
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: commit-discipline
Source: https://github.com/laicluse/agent-fieldkit/tree/main/.agents/plugins/generated/git-discipline/skills/commit-discipline
Command: npx skills add https://github.com/laicluse/agent-fieldkit --skill commit-discipline-laicluse

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Enforcing consistent, meaningful commit messages across a team is hard: subjects get vague, bodies get skipped, and verification claims go unchecked. This Skill defines and enforces a structured commit body schema (subject, WHY paragraph, and trailers like Slice, Tests, Red-then-green, Visual, and Verified) through a PreToolUse guard plus git-native hooks, so every commit carries reviewable context. ## Core Features & Use Cases - Structured commit schema: Validates imperative subjects (50/72 chars), a WHY paragraph, and required trailers parsed via git interpret-trailers, with opt-out tokens (docs-only, config-only, wip, and more) for housekeeping commits. - Two-layer enforcement: A PreToolUse:Bash guard intercepts agent-driven commits while git-native hooks (commit-msg, pre-push, post-rewrite, prepare-commit-msg) cover terminal commits, rebases, and pushes, including a wip-commit push block. - Audit and troubleshooting tooling: A shadow-log audit script summarizes guard violations and supports true/false labeling to measure false-positive rates; the reference documents every error code and escape hatch. - Use Case: An agent attempts git commit with multiple -m flags and gets denied with missing-slice; the Skill's canonical heredoc form and single-attempt checklist let it fix all reported violations in one retry. ## Quick Start Ask the agent to commit the staged changes following the git-discipline commit body schema with the required Slice, Tests, Red-then-green, and Verified trailers.

Frequently Asked Questions about commit-discipline

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write a git commit message that passes the git-discipline validator?▼

Use a single heredoc with git commit -m containing an imperative subject under 50 chars, a WHY paragraph of 60+ chars, and contiguous trailers (Slice, Tests, Red-then-green, Verified) at the bottom. Multiple -m flags fail because git interpret-trailers only reads the last paragraph.

Why does my commit fail with missing-slice even though I included a Slice trailer?▼

The failure is almost always structural, not the token itself. Multiple -m flags split trailers into separate paragraphs that git interpret-trailers cannot see, and embedded newlines inside a -m argument truncate the extracted body. Use the canonical heredoc form instead.

Can I bypass the commit-msg hook for an emergency commit?▼

Yes, git commit --no-verify bypasses the git-native hook, but the post-commit hook detects the bypass via a trace-file recency check and logs it to git-discipline-no-verify.log for later audit. There is no magic-comment bypass at the git-native layer.

What commit types are exempt from the full trailer requirements?▼

Eight Slice opt-out tokens relax the rules: docs-only, config-only, migration-only, spec-only, chore-deps, revert, merge, and wip. These drop the Tests requirement, and the first five also drop Red-then-green; wip commits are accepted locally but blocked at push.

When is the Visual trailer required in a commit?▼

The Visual trailer is required when the staged diff touches UI files: web templates, stylesheets, storyboards, asset catalogs, or Swift files importing SwiftUI/UIKit. Backend-only commits skip it, and false positives can use Visual: n/a with a rationale from the closed enum.

Does the validator work with rebased or amended commits?▼

Yes, through backstop layers. A post-rewrite hook validates rewritten bodies with warn-and-log (git ignores its exit status), and pre-push re-validates every commit body in the push range as the final gate before code reaches a remote.