From petems-skills
Set up prek git hooks with sensible defaults and language-specific linters
How this skill is triggered — by the user, by Claude, or both
Slash command
/petems-skills:prek-setup-petemsThis skill is limited to the following tools:
The summary Claude sees in its skill listing — used to decide when to auto-load this skill
When the user asks you to set up prek (or pre-commit hooks using prek), follow these steps carefully.
When the user asks you to set up prek (or pre-commit hooks using prek), follow these steps carefully.
Look for existing hook configuration files:
prek.toml.pre-commit-config.yamlIf either exists, ask the user whether to overwrite, merge with the new config, or leave it unchanged. Do not proceed until the user confirms. If the user chooses leave it unchanged, stop the workflow and report that no changes were made.
Check if prek is available:
command -v prek
If not found, ask the user which installation method they prefer:
brew install prek (macOS/Linuxbrew)cargo install prek (Rust toolchain)pipx install prek (Python)After installation, verify with:
prek --version
Use Glob to check for marker files that indicate which languages the project uses:
| Marker files | Language |
|---|---|
pyproject.toml, setup.py, requirements.txt, Pipfile | Python |
package.json | JavaScript/TypeScript |
go.mod | Go |
Cargo.toml | Rust |
Gemfile, *.gemspec | Ruby |
**/*.tf | Terraform |
Package.swift, *.xcodeproj | Swift |
pom.xml, build.gradle, build.gradle.kts | Java/Kotlin |
**/*.sh | Shell |
**/*.md, hugo.toml, hugo.yaml, config.toml (Hugo), mkdocs.yml | Markdown/Blog |
Report detected languages to the user before continuing.
prek.tomlBuild a prek.toml config file using the native TOML format (recommended by prek).
[[repos]]
repo = "https://github.com/pre-commit/pre-commit-hooks"
rev = "v6.0.0"
hooks = [
{ id = "trailing-whitespace" },
{ id = "end-of-file-fixer" },
{ id = "check-yaml" },
{ id = "check-json" },
{ id = "check-merge-conflict" },
{ id = "detect-private-key" },
{ id = "check-added-large-files" },
]
Only include sections for detected languages:
Python:
[[repos]]
repo = "https://github.com/astral-sh/ruff-pre-commit"
rev = "v0.15.7"
hooks = [
{ id = "ruff", args = ["--fix"] },
{ id = "ruff-format" },
]
JavaScript/TypeScript:
[[repos]]
repo = "https://github.com/pre-commit/mirrors-prettier"
rev = "v3.1.0"
hooks = [
{ id = "prettier" },
]
Go:
[[repos]]
repo = "https://github.com/golangci/golangci-lint"
rev = "v2.11.3"
hooks = [
{ id = "golangci-lint" },
]
Rust:
[[repos]]
repo = "local"
hooks = [
{ id = "cargo-fmt", name = "cargo fmt", entry = "cargo fmt --", language = "system", types = ["rust"] },
{ id = "cargo-clippy", name = "cargo clippy", entry = "cargo clippy --all-targets --all-features -- -D warnings", language = "system", types = ["rust"], pass_filenames = false },
]
Ruby:
[[repos]]
repo = "https://github.com/rubocop/rubocop"
rev = "v1.85.1"
hooks = [
{ id = "rubocop" },
]
Terraform:
[[repos]]
repo = "https://github.com/antonbabenko/pre-commit-terraform"
rev = "v1.105.0"
hooks = [
{ id = "terraform_fmt" },
{ id = "terraform_validate" },
{ id = "terraform_tflint" },
]
Swift:
[[repos]]
repo = "https://github.com/nicklockwood/SwiftFormat"
rev = "0.60.1"
hooks = [
{ id = "swiftformat" },
]
[[repos]]
repo = "https://github.com/realm/SwiftLint"
rev = "0.63.2"
hooks = [
{ id = "swiftlint" },
]
Shell:
[[repos]]
repo = "https://github.com/shellcheck-py/shellcheck-py"
rev = "v0.11.0.1"
hooks = [
{ id = "shellcheck" },
]
Java/Kotlin:
[[repos]]
repo = "https://github.com/macisamuele/language-formatters-pre-commit-hooks"
rev = "v2.16.0"
hooks = [
{ id = "pretty-format-java", args = ["--autofix"] },
{ id = "pretty-format-kotlin", args = ["--autofix"] },
]
Markdown/Blog:
[[repos]]
repo = "https://github.com/igorshubovych/markdownlint-cli"
rev = "v0.48.0"
hooks = [
{ id = "markdownlint", args = ["--fix"] },
]
[[repos]]
repo = "https://github.com/pre-commit/mirrors-prettier"
rev = "v3.1.0"
hooks = [
{ id = "prettier", types_or = ["markdown", "yaml"], args = ["--prose-wrap", "preserve"] },
]
Show the assembled prek.toml to the user and ask for confirmation before writing it. Make any requested adjustments first.
Run prek install, handling potential global hooksPath conflicts:
git -c core.hooksPath=.git/hooks prek install
Run prek across all files to catch and auto-fix issues:
prek run --all-files
If there are auto-fixable issues, let prek fix them and re-run up to 3 times. If issues still remain (or output does not converge), stop and report remaining failures for manual intervention.
Stage only the new prek.toml and files modified by this prek run (do not stage unrelated pre-existing changes), then do not commit.
Tell the user:
prek autoupdate later to pin hooks to the latest revisionsGuides creation, editing, and verification of skills for AI coding agents using test-driven development with subagent scenarios. Use when authoring or debugging skills.
npx claudepluginhub petems/petems-skills --plugin blog-post-writer-petems