Repository navigation
chore: add pre-commit hooks (file hygiene, secrets, markdown, rust, commits) - #10
Conversation
…ommits) Adds a pre-commit framework configuration with five hook groups: - File hygiene: trailing-whitespace, end-of-file-fixer, check-yaml/toml/json, check-merge-conflict, mixed-line-ending (LF), detect-private-key, check-added-large-files (1 MiB cap). - Secret detection: gitleaks v8.21.2. - Markdown lint: markdownlint-cli2 with a relaxed config that disables rules that fight Japanese line widths and legitimate inline HTML. - Conventional Commits validator: compilerla/conventional-pre-commit on the commit-msg stage with the standard 11-type allowlist. - Rust local hooks: `cargo fmt --check` and `cargo clippy --all-targets -- -D warnings`, matching the CI gate. CI runs the same set via the new `pre-commit` job (libdbus pre-installed so the cargo hooks can build keyring's transitive deps; rustfmt + clippy components pinned on the dtolnay toolchain action). README and README.ja.md gained a "pre-commit hooks" subsection under Development pointing contributors at `pre-commit install` plus the `commit-msg` hook type. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Warning Rate limit exceeded
You’ve run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📝 WalkthroughWalkthroughThis PR adds a pre-commit hook framework to enforce code quality checks locally and in CI. It introduces a hook configuration pipeline, markdown linting rules, a new CI job, and developer documentation in both English and Japanese. ChangesPre-commit hook infrastructure
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.pre-commit-config.yaml:
- Line 14: Update the pinned versions in .pre-commit-config.yaml for the listed
hooks: set pre-commit-hooks rev to v6.0.0, gitleaks rev to v8.30.1,
markdownlint-cli2 rev to v0.22.1, and conventional-pre-commit rev to v4.4.0;
locate the rev lines for each hook (references: "pre-commit-hooks", "gitleaks",
"markdownlint-cli2", "conventional-pre-commit") and replace the old tag strings
with the new versions, then run pre-commit autoupdate or a local pre-commit run
to verify there are no compatibility issues.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: ca1f64f8-a1b1-4313-b4a6-324c26ac1ccc
📒 Files selected for processing (5)
.github/workflows/ci.yml.markdownlint-cli2.yaml.pre-commit-config.yamlREADME.ja.mdREADME.md
CI's pre-commit job failed on the first run for two reasons:
1. markdownlint flagged six MD040/MD032 violations in
docs/superpowers/{plans,specs}/*.md — those are internal
brainstorming / implementation notes, not user-facing docs.
Add `docs/superpowers/**` to the markdownlint ignore list.
2. The local cargo hooks used plain `cargo`, which resolves through
the host's rustup default. On the contributor machine that ended
up being a stale 1.80.1 toolchain even though `mise.toml` pins
1.89, so the hook errored with "rustc 1.80.1 is not supported".
Route both cargo hooks through `mise exec --` so the pinned
toolchain is always used.
CI's pre-commit job now installs mise (with GITHUB_TOKEN for the ubi
backend rate limit), then `rustup component add rustfmt clippy`
guarantees the components are present.
Local verification: `pre-commit run --all-files` now passes all 13
hooks (file hygiene, gitleaks, markdownlint, cargo fmt, cargo clippy).
The `commit-msg` hook is also installed so this very commit went
through the conventional-pre-commit validator.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Address CodeRabbit's review on PR #10: the pinned hook revs were stale. Ran `pre-commit autoupdate` and bumped: - pre-commit-hooks v5.0.0 -> v6.0.0 - gitleaks v8.21.2 -> v8.30.0 - markdownlint-cli2 v0.14.0 -> v0.22.1 - conventional-pre-commit v3.6.0 -> v4.4.0 markdownlint-cli2 v0.22 enabled MD060/table-column-style by default, which fires on every row of README/README.ja.md tables that mix full-width Japanese characters with ASCII. Pipe alignment for those tables would only be byte-accurate, not visually accurate, so disable the rule in `.markdownlint-cli2.yaml` with a comment. Local `pre-commit run --all-files` passes all 13 hooks. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
macos test failed at the clippy step with `error: unexpected argument 'clippy' found`. The previous `rustup component add rustfmt clippy` step had rustup install a *fresh* 1.89 toolchain (separate from the mise-managed one) and dropped the components there. The next step called `cargo clippy` via the mise toolchain, which did not see clippy. Run every cargo / rustup invocation in the test matrix through `mise exec --` so all OSes use the mise-managed toolchain consistently. No change to deny / msrv / linux-headless jobs. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.github/workflows/ci.yml:
- Around line 95-97: The step "ensure rustfmt + clippy components" in the
pre-commit job installs components into the default toolchain; change that to
install into the mise toolchain so hooks run against the same toolchain—replace
the current run command with one that targets the mise toolchain (for example
use rustup +mise component add rustfmt clippy or rustup component add
--toolchain mise rustfmt clippy) so cargo fmt/clippy are installed into the mise
toolchain used by the pre-commit hooks.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 275ef592-d9d9-4d1a-b77e-41415efa5c4f
📒 Files selected for processing (3)
.github/workflows/ci.yml.markdownlint-cli2.yaml.pre-commit-config.yaml
🚧 Files skipped from review as they are similar to previous changes (1)
- .pre-commit-config.yaml
…up through mise Two related fixes: 1. test (macos-latest) kept failing with `cargo clippy: unexpected argument 'clippy' found` because `mise exec -- rustup component add` on macOS spun up a *separate* rustup 1.89 toolchain (the host's pre-installed rustup, not mise's), and the subsequent `mise exec -- cargo clippy` resolved to mise's cargo which never saw the new components. The test matrix only needs rust + cargo-nextest, so drop mise from that job and install rust via `dtolnay/rust-toolchain` with explicit `components: rustfmt, clippy`. This is what the pre-commit job already implied: mise is only for the cargo hooks invoked from `pre-commit run`, not for the cargo commands the test matrix runs directly. 2. CodeRabbit flagged that the pre-commit job's `rustup component add rustfmt clippy` runs against the host's rustup, which can diverge from the mise toolchain that the pre-commit cargo hooks (`mise exec -- cargo ...`) actually use. Route that rustup invocation through `mise exec` so the components land in the same toolchain. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
What
pre-commitframework を使った hook 群を追加します。Hook 構成
追加ファイル
.pre-commit-config.yaml(94 行) — hooks 宣言.markdownlint-cli2.yaml(12 行) — line-length / no-inline-html などを disable(日本語 README + jsonc fenced block 対応)変更ファイル
.github/workflows/ci.yml— 新 jobpre-commitを追加。libdbus を pre-install (cargo hook が keyring 経由で必要)、dtolnay rust-toolchain で rustfmt + clippy components を install、pre-commit/action@v3.0.1を SHA pin で実行README.md/README.ja.md— Development セクションに pre-commit install 手順を追加Why
pre-commit install1 行で同一環境Testing
mise exec -- cargo fmt --check→ cleanmise exec -- cargo clippy --all-targets -- -D warnings→ cleanruby -ryaml -e ...で全 YAML (.pre-commit-config.yaml,.markdownlint-cli2.yaml,.github/workflows/ci.yml) の syntax 検証 → okpre-commit run --all-files通過確認 → 本 PR の CI で検証Checklist
chore: ...)🤖 Generated with Claude Code
Summary by CodeRabbit
Chores
Documentation
Style