一键导入
git-commit-discipline
Git commit hygiene for AI agents - atomic commits, Conventional Commits, secret scanning, branch safety, history protection
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Git commit hygiene for AI agents - atomic commits, Conventional Commits, secret scanning, branch safety, history protection
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Make Codex CLI behave more like Claude Code for Kookr by preserving the known fork, branch, build, deploy, daily upstream sync, and live-verification workflow for Claude-compatible skills, agents, settings, hooks, and related UX.
Kookr-internal extension to rfc-iterative-review that captures append-only critic traces for later meta-analysis of RFC reviewer subagents.
Analyze an open question by casting 3-5 deliberately conflicting expert roles, running them in parallel and blind to each other, sharpening them in a debate round, attacking their consensus with a devil's advocate, then synthesizing a verdict that preserves disagreement instead of averaging it. Use for decisions, strategy, idea generation, hypothesis triage, experiment post-mortems, or any question where a single lens would return "it depends".
Iterative RFC drafting workflow — draft in worktree, run parallel critic subagents, incorporate feedback over N rounds, present to user before any action
How to create, structure, and launch Kookr playbook tasks — reusable agent task templates with dynamic sources and project identity
Build a Ralph-like sequential Kookr task chain where each task completes one independent unit, records durable state, and spawns the next task with the same continuation contract. Use for issue batches, queue drains, staged migrations, or other long runs that should proceed one task at a time without relying on conversation memory.
| name | git-commit-discipline |
| description | Git commit hygiene for AI agents - atomic commits, Conventional Commits, secret scanning, branch safety, history protection |
| keywords | git commit, commit message, atomic commit, conventional commits, git add, gitignore, secret scan, force push, branch protection, commit hygiene, monolithic commit, commit discipline |
Rules for AI agents making git commits that are safe, atomic, traceable, and CI-friendly.
Research: docs/deepresearch/reports/Git Commit Discipline for AI Coding Agents.md
| # | Rule | Violation Example | Correct Pattern |
|---|---|---|---|
| 1 | Conventional Commits | git commit -m "fix" | git commit -m "fix(auth): prevent token reuse after logout" |
| 2 | Atomic commits | One commit with feature + refactor + docs | Separate commits per logical change |
| 3 | Never commit to main/master | git push origin main | Work on feature branch, merge via PR/quality-gate |
| 4 | No git add . | git add . (catches junk, secrets) | git add src/file.ts test/file.test.ts (named files) |
| 5 | No force-push on shared branches | git push -f origin develop | git push --force-with-lease on personal branches only |
| 6 | Never commit secrets | git add .env | Scan staged files; block .env*, tokens, API keys |
| 7 | Never bypass quality gates | git commit --no-verify | Run lint + tests + commitlint before every commit |
| 8 | Body explains WHY | Subject-only commit for non-trivial changes | Add body with motivation, not implementation details |
| 9 | Commits must not break CI | Committing code that fails lint/tests | Verify green before committing |
| 10 | Always --no-ff for merges | git merge feature (fast-forward) | git merge --no-ff feature -m "Merge: description" |
<type>(<scope>): <imperative summary>
<body: why this change was needed>
<footer: references, breaking changes>
| Type | Use When |
|---|---|
feat | New feature (correlates with MINOR in SemVer) |
fix | Bug fix (correlates with PATCH) |
refactor | Code change that neither fixes a bug nor adds a feature |
docs | Documentation only |
test | Adding or correcting tests |
chore | Build process, CI, tooling |
perf | Performance improvement |
style | Formatting, whitespace (no logic change) |
# WRONG
git commit -m "update"
git commit -m "stuff"
git commit -m "wip"
# CORRECT
git commit -m "feat(auth): add OAuth2 PKCE flow
Implements RFC 7636 to protect against authorization code
interception attacks on public clients.
BREAKING CHANGE: /oauth/token now requires code_verifier for public clients.
Closes #4721"
# Trivial (one-liner OK)
git commit -m "docs: fix typo in README"
git commit -m "style: format with biome"
One logical change per commit. A commit should be independently revertable without breaking unrelated functionality.
# WRONG: monolithic commit mixing concerns
git add .
git commit -m "big feature"
# Mixes: new feature + refactor + formatting + bugfix + docs
# CORRECT: staged, atomic commits
git add src/services/user-service.ts
git commit -m "refactor: extract UserService from UserController"
git add src/routes/password-reset.ts src/services/password-service.ts
git commit -m "feat: add password reset endpoint"
git add docs/api-reference.md
git commit -m "docs: update API reference for password reset"
| Metric | Threshold | Action |
|---|---|---|
| Lines changed | > 400 | Split into multiple commits |
| Unrelated files | > 3 | Separate by concern |
| Mixed types | feat + fix in one | Separate commits |
# WRONG: direct push to protected branch
git commit -am "quick fix"
git push origin main
# CORRECT: feature branch workflow
git checkout -b feat/password-reset
# ... make changes, commit atomically ...
# Merge via quality-gate or PR (--no-ff enforced)
AegisCore-specific: Worker agents use workflow/<type>/<branch-id> branches. Never commit directly to main or develop.
# WRONG: stages everything including junk
git add .
git add -A
# CORRECT: explicit file selection
git add src/routes/auth.ts src/services/auth-service.ts
git add tests/auth.test.ts
# CORRECT: interactive hunk staging for mixed changes
git add -p # Review each hunk individually
Before any git add, verify no junk files are staged:
| Pattern | Why It's Dangerous |
|---|---|
node_modules/ | Bloats repo (hundreds of MB) |
.env, .env.* | Contains secrets |
dist/, build/ | Generated artifacts |
.DS_Store | OS metadata |
*.pyc, __pycache__/ | Compiled bytecode |
*.log | Runtime logs |
data/, *.sqlite | Runtime data |
Before every commit, scan staged files for:
sk-, pk_, AKIA, etc.)-----BEGIN.*PRIVATE KEY-----)# Check for common secret patterns in staged files
git diff --cached --name-only | xargs grep -l -E \
'(sk-|pk_|AKIA|password|secret|token|-----BEGIN)' 2>/dev/null
# If found: BLOCK the commit, alert the user
If a secret was already committed:
git filter-repo or BFGgit rm is sufficient (it stays in history)# WRONG: rewriting shared history
git commit --amend # on already-pushed commits
git push -f origin develop
git rebase -i HEAD~5 # on pushed branch
# CORRECT: only rewrite local/unpushed history
git commit --amend # only if NOT pushed yet
git push --force-with-lease origin feat/my-branch # safer than -f
# CORRECT: squash via PR merge strategy (not rebase)
# Let the merge tool handle squashing, not manual rebase
Rule: Never git push -f on any branch that has been pushed, unless it is a personal feature branch less than 24 hours old. Prefer --force-with-lease.
Every commit must pass quality gates before creation:
# Pre-commit checklist (automated via hooks)
1. Lint check (biome + eslint)
2. Type check (bun run typecheck)
3. Unit tests (affected files)
4. Secret scan (staged files)
5. Commit message format (commitlint / Conventional Commits)
Rule: If any gate fails, fix the issue and create a NEW commit. Never --no-verify to skip hooks. Never --amend a previous commit to work around a hook failure (this destroys the previous commit's content).
Autonomous agents MUST commit incrementally to protect progress against interruption (context exhaustion, cost limits, crashes). Uncommitted work is LOST on failure — worktrees are force-cleaned on error.
Commit after any of these:
| Trigger | Examples |
|---|---|
| 1 function/method implemented or modified | New route handler, service method, utility function |
| 1 test file written or updated | auth.test.ts with its test cases |
| 1 module/class completed | New service class, new config file |
| 3+ files modified since last commit | Regardless of whether a "unit" feels complete |
| A bug fix that makes a test pass | Failing test → passing = commit immediately |
| A config or schema change | Migration file, .env.example, tsconfig.json |
| Before a risky operation | Large refactor, dependency upgrade, deleting code |
| User explicitly asks to commit | commit your changes, commit fixes first, commit local changes |
| Before cleanup or live-state operations | Removing worktrees, cleaning branches, restarting services, triggering workflows, reproducing against live state |
Rule of thumb: if reverting your uncommitted changes would lose more than ~50 lines of meaningful work, you should have already committed.
Treat commit reminders as hard operator constraints, not soft preferences.
wip: checkpoint rather than waiting for a perfect final commit.# Use wip: prefix for in-progress checkpoints
git commit -m "wip(auth): implement token validation logic
Progress checkpoint - session protection."
# Final commit uses standard Conventional Commits
git commit -m "feat(auth): add OAuth2 PKCE flow"
Checkpoint commits are squashed at merge time by the quality-gate, so frequent wip: commits have zero cost to final history cleanliness. Prefer committing too often over not enough.
Before committing, verify:
git add . or git add -A (use named files).env, secrets, or credentials stageddist/, node_modules/, build/)--no-verify or --amend on pushed commits--no-ffmerge-handler - Operational merge commands and conflict resolution git-merge-advanced - AI-assisted merge resolution and retry patterns git-worktree-cleanup - Branch and worktree lifecycle management workflow-reliability - Workflow state sync and recovery code-review-discipline - PR scope, self-review checklists, review feedback handling