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

Commit 7cadd2a

Browse files
Cragsmannclaude
andcommitted
feat: add commit-msg hook and simplify session-commit
Add Husky pre-commit (lint) and commit-msg hooks. The commit-msg hook validates conventional commit type prefix, authorship trailer (Co-Authored-By or Signed-off-by), and rejects em dashes. Merge, fixup, and squash commits are exempt. Simplify session-commit: remove progress log and blocker migration steps, add hook failure handling. Remove redundant commit-user command. Co-Authored-By: Claude <noreply@anthropic.com>
1 parent df9744c commit 7cadd2a

7 files changed

Lines changed: 84 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

.husky/pre-commit

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/usr/bin/env sh
2+
3+
yarn lint
4+
yarn type-check
5+
6+
cd backend
7+
go vet ./...
8+
if [ -n "$(gofmt -l .)" ]; then
9+
echo "Go files not formatted. Run: gofmt -w backend/"
10+
gofmt -l .
11+
exit 1
12+
fi

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
"cypress-merge": "mochawesome-merge ./integration-tests/screenshots/cypress_report*.json > ./integration-tests/screenshots/cypress.json",
2525
"cypress-generate": "marge -o ./integration-tests/screenshots/ -f cypress-report -t 'OpenShift Console Plugin Template Cypress Test Results' -p 'OpenShift Cypress Plugin Template Test Results' --showPassed false --assetsDir ./integration-tests/screenshots/cypress/assets ./integration-tests/screenshots/cypress.json",
2626
"cypress-postreport": "yarn cypress-merge && yarn cypress-generate",
27+
"type-check": "tsc --noEmit",
28+
"prepare": "husky",
2729
"webpack": "node -r ts-node/register ./node_modules/.bin/webpack"
2830
},
2931
"devDependencies": {
@@ -55,6 +57,7 @@
5557
"eslint-plugin-react": "^7.37.5",
5658
"eslint-plugin-react-hooks": "^7.0.1",
5759
"globals": "^17.4.0",
60+
"husky": "^9.1.7",
5861
"i18next": "^23.11.5",
5962
"i18next-parser": "^9.4.0",
6063
"jsdom": "^29.0.2",

tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"strict": true,
1111
"allowSyntheticDefaultImports": true,
1212
"noUnusedLocals": true,
13+
"skipLibCheck": true,
1314
"types": ["vitest/globals"]
1415
},
1516
"include": ["src", "testing"],

yarn.lock

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5559,6 +5559,7 @@ __metadata:
55595559
eslint-plugin-react: "npm:^7.37.5"
55605560
eslint-plugin-react-hooks: "npm:^7.0.1"
55615561
globals: "npm:^17.4.0"
5562+
husky: "npm:^9.1.7"
55625563
i18next: "npm:^23.11.5"
55635564
i18next-parser: "npm:^9.4.0"
55645565
jsdom: "npm:^29.0.2"
@@ -8987,6 +8988,15 @@ __metadata:
89878988
languageName: node
89888989
linkType: hard
89898990

8991+
"husky@npm:^9.1.7":
8992+
version: 9.1.7
8993+
resolution: "husky@npm:9.1.7"
8994+
bin:
8995+
husky: bin.js
8996+
checksum: 10c0/35bb110a71086c48906aa7cd3ed4913fb913823715359d65e32e0b964cb1e255593b0ae8014a5005c66a68e6fa66c38dcfa8056dbbdfb8b0187c0ffe7ee3a58f
8997+
languageName: node
8998+
linkType: hard
8999+
89909000
"hyperdyperid@npm:^1.2.0":
89919001
version: 1.2.0
89929002
resolution: "hyperdyperid@npm:1.2.0"

0 commit comments

Comments
 (0)