Skip to content
This repository was archived by the owner on Jun 26, 2026. It is now read-only.

Commit 979bfb9

Browse files
Cragsmannclaude
andcommitted
feat: add commit-msg hook and simplify session-commit
Add a Husky commit-msg hook that validates conventional commit type prefix, authorship trailer, and no em dashes. Remove the redundant commit-user command and strip progress/blocker logging from session-commit. Co-Authored-By: Claude <noreply@anthropic.com>
1 parent b88fa30 commit 979bfb9

3 files changed

Lines changed: 58 additions & 51 deletions

File tree

.claude/commands/commit-user.md

Lines changed: 0 additions & 21 deletions
This file was deleted.

.claude/commands/session-commit.md

Lines changed: 13 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,31 @@
11
---
2-
allowed-tools: Bash(git *), Read, Edit, Write
3-
description: Stage changes, update progress log, and commit (end-of-session)
2+
allowed-tools: Bash(git *)
3+
description: Stage changes and commit (end-of-session)
44
---
55

66
# Session Commit
77

8-
Automate end-of-session cleanup: stage, log progress, commit.
8+
Automate end-of-session cleanup: stage and commit.
99

1010
## Steps
1111

12-
1. **Assess changes** run these in parallel:
12+
1. **Assess changes** -- run these in parallel:
1313
- `git status`
1414
- `git diff HEAD`
1515
- `git branch --show-current`
1616
- `git log --oneline -10`
1717

18-
2. **Stage everything** if there are unstaged or untracked changes:
18+
2. **Stage everything** -- if there are unstaged or untracked changes:
1919
- Use `git add <specific-files>` (not `git add .`)
2020
- Never stage files that likely contain secrets (.env, credentials, etc.)
2121
- Skip if everything is already staged
2222

23-
3. **Update progress log** — read `docs/claude-progress.txt`, then prepend a new entry at the top (after the header line) following the format in `docs/references/claude-progress-readme.md`.
24-
- Analyze the staged diff to determine what was done
25-
- Use today's actual date
26-
- Be concise but complete
27-
- Stage the updated file: `git add docs/claude-progress.txt`
23+
3. **Draft and commit** -- follow all rules from `docs/references/commit-message-guide.md`:
24+
- Subject: `<type>: <description>`, imperative mood
25+
- Body is optional if the subject is descriptive enough, otherwise explain what and why
26+
- No em dashes anywhere in the message
2827

29-
4. **Migrate blockers** — if the progress entry you just wrote has a `Blockers:` line that is NOT `None`:
30-
- Read `docs/agent-struggles.json`
31-
- For each blocker, append an entry:
32-
33-
```json
34-
{
35-
"date": "<today>",
36-
"description": "<blocker text from progress entry>",
37-
"cause": "<your best short assessment>",
38-
"suggestion": "<what would fix or prevent this>",
39-
"resolved": false
40-
}
41-
```
42-
43-
- Stage: `git add docs/agent-struggles.json`
44-
45-
5. **Draft and commit** — follow all rules from `docs/references/commit-message-guide.md`. Determine authorship mode (tandem vs autonomous) from the guide. Use a HEREDOC:
28+
Determine authorship mode (tandem vs autonomous) from the guide. Use a HEREDOC:
4629

4730
```bash
4831
git commit -m "$(cat <<'EOF'
@@ -55,11 +38,11 @@ Automate end-of-session cleanup: stage, log progress, commit.
5538
)"
5639
```
5740
58-
6. **Verify** run `git status` and `git log --oneline -1` to confirm success.
41+
4. **Verify** -- run `git status` and `git log --oneline -1` to confirm success. If the commit fails due to the commit-msg hook, read the error output, fix the message, and create a NEW commit (never amend).
5942
6043
## Rules
6144
62-
- Analyze the FULL diff for accurate progress and commit message
45+
- Analyze the FULL diff for an accurate commit message
6346
- Never commit secrets or sensitive files
64-
- If commit fails due to pre-commit hook, fix and create a NEW commit (never amend)
47+
- If commit fails due to pre-commit or commit-msg hook, fix and create a NEW commit (never amend)
6548
- Do NOT push to remote

.husky/commit-msg

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/usr/bin/env sh
2+
3+
MSG_FILE="$1"
4+
5+
# Strip comment lines
6+
MSG=$(grep -v '^#' "$MSG_FILE")
7+
8+
SUBJECT=$(echo "$MSG" | head -1)
9+
10+
# Skip merge, fixup, and squash commits
11+
case "$SUBJECT" in
12+
Merge\ branch\ *|Merge\ remote-tracking\ *|Merge\ tag\ *) exit 0 ;;
13+
fixup\!\ *|squash\!\ *) exit 0 ;;
14+
esac
15+
16+
ERRORS=""
17+
18+
# 1. Conventional commit format
19+
TYPES="feat|fix|refactor|docs|test|chore|style|perf|ci|build"
20+
if ! echo "$SUBJECT" | grep -qE "^($TYPES): .+"; then
21+
ERRORS="$ERRORS
22+
Subject must match '<type>: <description>'.
23+
Types: feat, fix, refactor, docs, test, chore, style, perf, ci, build"
24+
fi
25+
26+
# 2. Authorship trailer
27+
if ! echo "$MSG" | grep -qE '^(Co-Authored-By|Signed-off-by): .+'; then
28+
ERRORS="$ERRORS
29+
Missing authorship trailer (Co-Authored-By or Signed-off-by)."
30+
fi
31+
32+
# 3. No em dashes
33+
if echo "$MSG" | grep -q ''; then
34+
ERRORS="$ERRORS
35+
Em dashes are not allowed. Use commas, periods, or parentheses."
36+
fi
37+
38+
if [ -n "$ERRORS" ]; then
39+
echo ""
40+
echo "commit-msg: FAILED"
41+
echo "$ERRORS"
42+
echo ""
43+
echo "See docs/references/commit-message-guide.md for rules."
44+
exit 1
45+
fi

0 commit comments

Comments
 (0)