
Commit
- 33 installs
- 269 repo stars
- Updated June 11, 2026
- gupsammy/claudest
Run staged-change-only lint and format checks before git commit so untouched files never block a clean diff.
About
commit packages a validate.py pre-commit workflow for Claude-style agents and solo developers who want discipline without running entire monorepo linters on every small change. From the project root it detects Rust, Node, or Python layouts via marker files, maps git staged paths to the right tool, and runs cargo fmt --check, ruff check, or npm run lint only when relevant extensions are staged. That design keeps unrelated legacy debt from blocking commits whose diffs are already clean—aligned with indie velocity while still catching formatting and lint regressions you introduced. Use it in Ship whenever you are about to commit; it also helps during Build iterations when you want the same gate locally instead of waiting for CI. The skill is intermediate because hook wiring, validator tables, and exit-code semantics must match your repo’s scripts. It is a checker-style procedural skill, not a hosted CI product.
- Auto-detects project type from root markers: Cargo.toml, package.json, pyproject.toml
- Validators scoped to staged files—pre-existing issues in untouched paths do not fail the commit
- Scope modes: per-file lists, package dirs, and extension-gated project-wide npm lint
- Exit codes 0 pass, 1 fail, 2 no applicable validator
- Supports text or JSON output for hook and agent consumption
Commit by the numbers
- 33 all-time installs (skills.sh)
- Ranked #348 of 733 Git & Pull Requests skills by installs in the Skillselion catalog
- Security screen: LOW risk (skills.sh audit)
- Data as of Aug 4, 2026 (Skillselion catalog sync)
npx skills add https://github.com/gupsammy/claudest --skill commitAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 33 |
|---|---|
| repo stars | ★ 269 |
| Security audit | 3 / 3 scanners passed |
| Last updated | June 11, 2026 |
| Repository | gupsammy/claudest ↗ |
What it does
Run staged-change-only lint and format checks before git commit so untouched files never block a clean diff.
Files
Commit
Analyze uncommitted changes and create well-organized commits using conventional commit format.
Workflow
1. Discover Changes
Current repo state (injected at invocation — no tool calls needed):
- Status: !
git status --porcelain - Diff stats: !
git diff --stat
Abort before staging if any apply:
- Not a git repository.
- No changes ("Nothing to commit").
- Mid-merge / rebase / cherry-pick / revert —
git add -Awould stage conflict markers as content. Check$(git rev-parse --git-dir)forMERGE_HEAD,CHERRY_PICK_HEAD,REVERT_HEAD,rebase-merge/, orrebase-apply/. If any present, report the in-progress operation and stop. - Detached HEAD —
git symbolic-ref -q HEADis empty. Commit would land on an unreferenced commit and be lost on branch switch. Report and stop.
2. Stage Files
Run git add -A to stage all changes.
Exclude generated or ephemeral files that should never be version-controlled: scratch.*, temp.*, debug.*, playground.*, *.log, dist/, build/, target/, node_modules/, __pycache__/.
If such files detected: 1. Unstage with git reset HEAD <file> 2. Ask user if they want to add to .gitignore
Proceed when all intended files are staged and ephemeral files are excluded.
3. Analyze Commit Boundaries
For each changed file, write a one-line PURPOSE description (not file location).
Group by PURPOSE, not directory:
- Same goal = one commit
- Different goals = separate commits
Each commit should represent one logical change because atomic commits enable git bisect and git revert without side-effects.
Signs of separate concerns:
- "Added X" AND "Fixed Y" (feature + bugfix)
- Changes that could be reverted independently
- Different conventional-commit types on related work — a fix and its tests go in separate
fix:andtest:commits so the fix can be reverted without losing the tests
If multiple concerns: use git reset HEAD then git add <specific-files> for each group. Commit foundational changes first.
Handle renames (R status): When splitting, add BOTH old and new paths. Git detects renames by similarity scoring across the old/new pair — staging only the new path causes git to log a delete + add, losing rename history.
Proceed when every changed file is assigned to exactly one commit group.
4. Validate
Run the validation script after staging:
python3 ${CLAUDE_PLUGIN_ROOT}/skills/commit/scripts/validate.py . --output jsonInterpret the result:
- Exit 0 → validation passed; proceed to Step 5
- Exit 1 → validation failed; parse the
outputfield, report the error to the user, and stop - Exit 2 → validator skipped (no marker file, no staged files match the validator's extensions, or the tool isn't installed); proceed to Step 5. The
outputfield names the reason.
5. Create Commit
Check recent commit style:
git log --no-merges --oneline -10Use conventional commit format:
<type>(<scope>): <description>Types: feat, fix, docs, refactor, test, chore, perf
- Lowercase subject, no period, imperative mood
- Max 72 chars for subject
- Omit Co-authored-by trailers and AI attribution — these pollute
git logand break downstream tooling that greps commit metadata - No emojis
If `git commit` fails due to a pre-commit hook: the commit did NOT land. Check git status — the hook may have auto-fixed files (e.g. auto-version.py syncing plugin.json) and left them modified. Re-stage (git add -A) and retry the same git commit command with the same message. Do NOT use --amend (amends the PREVIOUS commit, not the failed one). Do NOT use --no-verify (skips the hook entirely, defeating its guard).
Proceed when the commit message is drafted and matches the repo's existing style.
6. Push (only if requested)
If user mentions "push" or arguments contain "push", run git push. If push fails, report the error and stop — do not retry or force-push.
Output
One line per commit (hash + message). If temporary files were excluded, list them as bullets below.
#!/usr/bin/env python3
"""Run project validation before committing.
Detects project type from the root directory and runs the appropriate
linter or build check scoped to the user's staged changes — not the
whole project. Pre-existing issues in untouched files never block a
commit whose diff is clean.
Exit codes:
0 — validation passed
1 — validation failed (see output for details)
2 — no validator applies (no marker file, or no relevant staged files)
Usage:
validate.py <project-root> [--output text|json]
"""
from __future__ import annotations
import argparse
import json
import os
import subprocess
import sys
from pathlib import Path
# scope semantics:
# "files" — pass filtered staged file list after cmd_prefix
# "dirs" — pass unique parent dirs of staged files (go-style packages)
# "gated" — run project-scope cmd only if any staged file matches extensions
VALIDATORS = [
{
"marker": "Cargo.toml",
"tool": "cargo",
"scope": "files",
"extensions": [".rs"],
"cmd_prefix": ["cargo", "fmt", "--check", "--"],
},
{
"marker": "package.json",
"tool": "npm",
"scope": "gated",
"extensions": [".js", ".jsx", ".ts", ".tsx", ".mjs", ".cjs"],
"cmd": ["npm", "run", "lint", "--if-present"],
},
{
"marker": "pyproject.toml",
"tool": "ruff",
"scope": "files",
"extensions": [".py"],
"cmd_prefix": ["ruff", "check"],
},
{
"marker": "go.mod",
"tool": "go",
"scope": "dirs",
"extensions": [".go"],
"cmd_prefix": ["go", "vet"],
},
{
"marker": "Gemfile",
"tool": "rubocop",
"scope": "files",
"extensions": [".rb"],
"cmd_prefix": ["bundle", "exec", "rubocop", "--no-color"],
"fallback_prefix": ["rubocop", "--no-color"],
},
{
"marker": "pom.xml",
"tool": "maven",
"scope": "gated",
"extensions": [".java"],
"cmd": ["mvn", "validate", "-q"],
},
{
"marker": "mix.exs",
"tool": "mix",
"scope": "files",
"extensions": [".ex", ".exs"],
"cmd_prefix": ["mix", "format", "--check-formatted"],
},
{
"marker": "composer.json",
"tool": "composer",
"scope": "gated",
"extensions": ["composer.json", "composer.lock"],
"cmd": ["composer", "validate", "--strict"],
},
]
def get_staged_files(root: Path) -> list[str]:
"""Return staged file paths relative to root. Empty list if git unavailable.
Uses --diff-filter=ACMR so renamed+edited files (git mv) reach validators
under their new path; otherwise R entries silently skip validation.
"""
try:
result = subprocess.run(
["git", "diff", "--cached", "--name-only", "--diff-filter=ACMR"],
cwd=str(root),
capture_output=True,
text=True,
timeout=30,
)
if result.returncode != 0:
if result.stderr.strip():
print(f"git diff failed: {result.stderr.strip()}", file=sys.stderr)
return []
return [line.strip() for line in result.stdout.splitlines() if line.strip()]
except subprocess.TimeoutExpired:
print("git diff timed out after 30s", file=sys.stderr)
return []
except FileNotFoundError:
return []
def match_extension(path: str, extensions: list[str]) -> bool:
"""True if path matches any extension entry.
Entries starting with '.' are treated as suffixes (e.g. '.py' matches any *.py).
Other entries are treated as exact basenames (e.g. 'composer.json' matches only
a file literally named composer.json, not vendor/mycomposer.json).
"""
basename = os.path.basename(path)
for ext in extensions:
if ext.startswith("."):
if path.endswith(ext):
return True
else:
if basename == ext:
return True
return False
def filter_by_extensions(files: list[str], extensions: list[str]) -> list[str]:
return [f for f in files if match_extension(f, extensions)]
def unique_package_dirs(files: list[str]) -> list[str]:
"""Collapse a file list into './dir/' paths, one per unique parent directory."""
dirs = set()
for f in files:
parent = os.path.dirname(f)
dirs.add(f"./{parent}/" if parent else "./")
return sorted(dirs)
def detect_validator(root: Path) -> dict | None:
for v in VALIDATORS:
if (root / v["marker"]).exists():
return v
return None
def build_command(validator: dict, staged: list[str]) -> list[str] | None:
"""Build the command to run. Returns None if validator's scope criteria aren't met."""
scope = validator["scope"]
exts = validator.get("extensions", [])
if scope == "files":
matched = filter_by_extensions(staged, exts)
if not matched:
return None
return validator["cmd_prefix"] + matched
if scope == "dirs":
matched = filter_by_extensions(staged, exts)
if not matched:
return None
return validator["cmd_prefix"] + unique_package_dirs(matched)
if scope == "gated":
if not filter_by_extensions(staged, exts):
return None
return validator["cmd"]
return None
def build_fallback(validator: dict, staged: list[str]) -> list[str] | None:
"""Some validators have a fallback tool (e.g. rubocop without bundler). Same scope rules."""
if "fallback_prefix" in validator:
matched = filter_by_extensions(staged, validator.get("extensions", []))
if not matched:
return None
return validator["fallback_prefix"] + matched
return None
COMMAND_TIMEOUT_SECONDS = 60
def run_command(cmd: list[str], cwd: Path) -> tuple[bool, str]:
try:
result = subprocess.run(
cmd,
cwd=str(cwd),
capture_output=True,
text=True,
timeout=COMMAND_TIMEOUT_SECONDS,
)
output = (result.stdout + result.stderr).strip()
return result.returncode == 0, output
except FileNotFoundError:
return False, f"Command not found: {cmd[0]}"
except subprocess.TimeoutExpired:
return False, f"{cmd[0]} timed out after {COMMAND_TIMEOUT_SECONDS}s"
def emit(args, payload: dict, *, is_error: bool = False) -> None:
if args.output == "json":
print(json.dumps(payload))
else:
msg = payload.get("output", "")
status = payload.get("status")
if status:
print(f"Validation {status} ({payload.get('tool', '?')})")
if msg:
stream = sys.stderr if is_error else sys.stdout
print(msg, file=stream)
def main() -> None:
parser = argparse.ArgumentParser(
description=__doc__,
formatter_class=argparse.RawDescriptionHelpFormatter,
)
parser.add_argument("project_root", help="Path to project root directory")
parser.add_argument(
"--output",
choices=["text", "json"],
default="text",
help="Output format (default: text)",
)
args = parser.parse_args()
root = Path(args.project_root).resolve()
if not root.is_dir():
emit(args, {"valid": False, "tool": None, "output": f"Not a directory: {root}"}, is_error=True)
sys.exit(1)
validator = detect_validator(root)
if validator is None:
emit(args, {
"valid": False,
"tool": None,
"output": "No validator found (no known marker file in project root)",
})
sys.exit(2)
staged = get_staged_files(root)
cmd = build_command(validator, staged)
if cmd is None:
emit(args, {
"valid": False,
"tool": validator["tool"],
"output": f"{validator['tool']}: no staged files match {validator.get('extensions', [])} — skipping",
})
sys.exit(2)
tool = validator["tool"]
valid, output = run_command(cmd, root)
if not valid and "not found" in output:
fallback = build_fallback(validator, staged)
if fallback is not None:
valid, output = run_command(fallback, root)
if not valid and "not found" in output:
emit(args, {
"valid": False,
"tool": tool,
"output": f"{tool} not installed; skipping validation",
})
sys.exit(2)
emit(args, {
"valid": valid,
"tool": tool,
"output": output,
"status": "passed" if valid else "failed",
})
sys.exit(0 if valid else 1)
if __name__ == "__main__":
main()
Related skills
FAQ
Is Commit safe to install?
skills.sh reports 3 of 3 security scanners passed. Review the Security Audits panel on this page before installing in production.