CRITICAL: Before running any build or test commands, check if the machine is on battery power:
${CLAUDE_PLUGIN_ROOT}/scripts/check-battery || { echo "⚡ Skipping precommit on battery power"; exit 0; }
git test run HEAD --retest --verbose --verbose
If on battery power, skip the build and report: "⚡ Skipped precommit checks (on battery power)"
If on AC power, proceed with the build
⚙️ Running Precommit
Run git test run HEAD --retest --verbose --verbose to validate code:
Use a timeout of at least 10 minutes
This command runs the test configured via git test add (typically autoformatting, builds, tests, and other quality checks)
📋 Handle Missing Configuration
If git test is not configured for this repository, clearly explain the situation and suggest running /build:test-setup to configure it.
❌ Handle Check Failures
When precommit fails (due to: type checking errors, test failures, linting issues, build errors):
Analyze the error output to understand what failed
Fix the specific failures
Run the precommit command again
Continue the fix-and-retry cycle until precommit completes successfully with exit code 0
✅ Reporting Results
Your final message MUST start with one of:
"⚡ Skipped precommit checks (on battery power)" - if skipped due to battery
Converted and distributed by TomeVault — claim your Tome and manage your conversions.
1---2name: precommit3description: Running precommit checks and build validation. ALWAYS use after ANY code changes. Use when this capability is needed.4---56# Precommit and Build Validation78## 🔋 Battery Check910**CRITICAL**: Before running any build or test commands, check if the machine is on battery power:1112```bash13${CLAUDE_PLUGIN_ROOT}/scripts/check-battery || { echo "⚡ Skipping precommit on battery power"; exit 0; }14git test run HEAD --retest --verbose --verbose15```1617- If on battery power, skip the build and report: "⚡ **Skipped precommit checks (on battery power)**"18- If on AC power, proceed with the build1920## ⚙️ Running Precommit2122Run `git test run HEAD --retest --verbose --verbose` to validate code:2324- Use a timeout of at least 10 minutes25- This command runs the test configured via `git test add` (typically autoformatting, builds, tests, and other quality checks)2627## 📋 Handle Missing Configuration2829If `git test` is not configured for this repository, clearly explain the situation and suggest running `/build:test-setup` to configure it.3031## ❌ Handle Check Failures3233When precommit fails (due to: type checking errors, test failures, linting issues, build errors):3435- Analyze the error output to understand what failed36- Fix the specific failures37- Run the precommit command again38- Continue the fix-and-retry cycle until precommit completes successfully with exit code 03940## ✅ Reporting Results4142Your final message MUST start with one of:4344- "⚡ **Skipped precommit checks (on battery power)**" - if skipped due to battery45- "✅ **Precommit checks passed**" - if ran successfully46- "✅ **Precommit checks passed** (after fixing [brief description])" - if fixed issues4748## Agents4950| Task | Use |51| ----------------------- | ------------------------------------ |52| Run precommit and fix | `build:precommit-runner` agent |53| Test all branch commits | `/build:test-branch` command |54| Test and autosquash | `build:build-fixer-autosquash` agent |5556---57> Converted and distributed by [TomeVault](https://tomevault.io/claim/motlin) — claim your Tome and manage your conversions.58<!-- tomevault:4.0:skill_md:2026-04-11 -->
Run npx get-skill add tomevault-io/precommit in your terminal (requires Node.js), paste this page's agent-chat prompt into Claude, Cursor, or any MCP-connected agent, or download the SKILL.md file and copy it into your agent's skills directory.
Running precommit checks and build validation. ALWAYS use after ANY code changes. Use when this capability is needed. It is listed under Coding & Dev Tools on SkillMD.
This skill has not completed SkillMD's automated safety review yet. Independent scanners report: SkillSpector: PASS, Skill Scanner: PASS. SkillMD never runs a skill's scripts for you; review the SKILL.md before installing.
This skill is tagged as working with Claude Code, Claude.ai, OpenAI Codex. SKILL.md is an open format, so most agents that read a skills directory can load it too.
Yes. Installing skills from SkillMD is free, and the skill stays under its author's original license.
tomevault-io (@tomevault-io) published this skill. Their other Agent Skills are listed on their SkillMD profile.