| name | commit |
| description | Pre-commit gate (format + lint + test) then create a conventional commit with explicit file staging. |
/commit
The enforcer. Nothing reaches the index without passing the gate.
Steps
1. Format check.
swift format --recursive Sources Tests --in-place
Then stage any formatting changes:
git add -u Sources Tests
2. Lint check.
swift format lint --recursive Sources Tests
If any violations: fix them. No // swiftlint:disable suppression without a comment explaining why it's a confirmed false positive. Re-run until exit 0.
3. Full test run.
swift test 2>&1
Must pass. If it fails: halt. Surface the failure.
4. Code review against staged changes.
git diff --cached
Run code review per .nidex/skills/review/SKILL.md. Apply findings. If any fix was applied, loop back to step 1. Max 2 loops, then escalate.
5. Stage files explicitly.
git add <file1> <file2> ...
Never git add -A or git add .. Use git status --short to enumerate what's staged. If something unintended shows up (e.g. Package.resolved changes you didn't intend), ask the user.
6. Compose the commit message. Conventional commits format:
<type>(<scope>): <short imperative description>
<optional body — wrap at 72 cols, explain WHY not WHAT>
Types: feat, fix, chore, test, docs, refactor, perf, style, build, ci.
Rules: imperative mood, <= 72 char subject, no emoji.
7. Commit.
git commit -m "$(cat <<'EOF'
<message>
EOF
)"
8. Confirm.
git log -1 --oneline
git status --short
If a pre-commit hook fails: the commit did not happen. Fix the issue, re-stage, and create a new commit. Never --amend after a hook failure.