Block pushes and commits to main with git hooks

pre-push rejects any push that would update refs/heads/main, however the
command is spelled; pre-commit and pre-merge-commit refuse commits while
main is checked out. npm install enables them via core.hooksPath. The
README documents the three layers of protection for main.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
christianandClaude Opus 5.5 committed 2026-10-21 00:39:56 +02:00
1 parent 183e44db62
commit 8b08c7b27a
6 files changed
+84 -1

No files matched your search

+7
View File
@@ -3,6 +3,7 @@
A tiny todo CLI that exists to try out [Claude Code](https://docs.claude.com/en/docs/claude-code) features.
```sh
npm install # once per clone: turns on the git hooks in .githooks/
npm test
npm start -- add "try Claude Code"
npm start -- done 1
@@ -18,6 +19,12 @@ npm start -- ls
| `.claude/skills/changelog/` | A custom skill — run `/changelog` |
| `.claude/agents/test-writer.md` | A custom subagent — "use the test-writer agent to…" |
### Protecting `main`
Changes reach `main` only through a PR that a human merges. Three layers, strongest first:
1. **Gitea branch protection** on `main` (set in the repo settings on code.westerkam.org): the only layer that can't be bypassed from a clone.
2. **Git hooks** in `.githooks/` (enabled by `npm install`): `pre-push` rejects any push that would update `main`, however it's spelled; `pre-commit` / `pre-merge-commit` refuse commits while `main` is checked out. `--no-verify` skips them.
3. **Claude Code deny rules** in `.claude/settings.json` for `git push … main`: a quick early stop, but they match command text, so they're easy to get around.
## Things to try
- *"There's a bug in how ids are assigned after removing a todo — find it and fix it with a test."*