Xpersona
P

precommit-setup

CLAWHUB · Unverified

Configures pre-commit hooks for linting, type checking, formatting, and testing

62
Rank
84
Safety
1.8k
Downloads

About

What it does, and when to use it.

Capability contract not published. No trust telemetry is available yet. 1.8K downloads reported by the source. Last updated 10/10/2026.

Avoid when

  • Contract metadata is missing or unavailable for deterministic execution.

Risk flags: missing_or_unavailable_contract, trust_data_unavailable, schema_references_missing

Install and run

Setup complexity: low.

clawhub skill install s17emme0e2m3cpf7k2jvp3a84984b8z9:nm-attune-precommit-setup
  1. Install using `clawhub skill install s17emme0e2m3cpf7k2jvp3a84984b8z9:nm-attune-precommit-setup` in an isolated environment before connecting it to live workloads.
  2. No published capability contract is available yet, so validate auth and request/response behavior manually.
  3. Review the upstream CLAWHUB listing at https://clawhub.ai/athola/nm-attune-precommit-setup before using production credentials.

Contract: missing

curl -s "https://www.xpersona.co/api/v1/agents/clawhub-athola-nm-attune-precommit-setup/snapshot"

Run-check

$0.02 USD

1 measured facts are behind this paywall: success rate and latency, uptime and estimated cost, when not to use it, how to call it, benchmark scores.

Agents pay $0.02 in USDC. A card payment is $0.50, the smallest a card allows.

Documentation

CLAWHUB

145,829 characters of source documentation, loaded on request.

Extracted files

5 files captured from the source.

SKILL.md

---
name: precommit-setup
description: Configures pre-commit hooks for linting, type checking, formatting, and testing
version: 1.9.8
triggers:
  - pre-commit
  - quality-gates
  - linting
  - type-checking
  - testing
  - setting up a new project or adding quality gates to an existing one
metadata: {"openclaw": {"homepage": "https://github.com/athola/claude-night-market/tree/master/plugins/attune", "emoji": "\ud83e\udd9e"}}
source: claude-night-market
source_plugin: attune
---

> **Night Market Skill** — ported from [claude-night-market/attune](https://github.com/athola/claude-night-market/tree/master/plugins/attune). For the full experience with agents, hooks, and commands, install the Claude Code plugin.


# Pre-commit Setup Skill

Configure a three-layer pre-commit quality system that
enforces linting, type checking, and testing before every
commit.

## When To Use

- Setting up a new project with code-quality enforcement
- Adding pre-commit hooks to an existing project
- Upgrading from basic linting to a full quality system
- Setting up monorepo or plugin architecture with
  per-component quality checks
- Updating pre-commit hook versions

## When NOT To Use

- Pre-commit hooks already configured and working optimally
- Project does not use git version control
- Team explicitly avoids pre-commit hooks for workflow reasons

## Philosophy: Three-Layer Defense

The system is organised in three layers, each with a
different cost / coverage tradeoff:

- **Layer 1 -- Standard hooks**: fast global checks
  (50-200ms total). Lints and type-checks every staged file.
- **Layer 2 -- Component-specific checks**: per-component
  lint, typecheck, and test (10-30s total). Only the
  components touched by the staged files are run.
- **Layer 3 -- Validation hooks**: project-specific
  structure and pattern checks (varies). Catches violations
  that generic linters miss.

This layering keeps the fast feedback loop fast while still
catching the slow / project-specific bugs before they land.

## Module Loading

The detailed configuration patterns are in modules; load
only the ones you need:

- `modules/standard-hooks.md` -- Layer 1 patterns for
  Python, Rust, and TypeScript (load when configuring base
  linters).
- `modules/component-level-hooks.md` -- Layer 2 monorepo
  scripts and pre-commit wiring (load when project has
  multiple components / plugins).
- `modules/validation-hooks.md` -- Layer 3 custom hooks
  and SKIP patterns (load when enforcing project conventions
  beyond linting).
- `modules/ci-integration.md` -- GitHub Actions workflow
  plus a complete `.pre-commit-config.yaml` example (load
  when wiring CI to mirror local checks).
- `modules/troubleshooting.md` -- timing tables, cache
  clearing, hook-failure recovery (load when hooks are slow
  or failing).

## Workflow

### 1. Create Configuration Files

\`\`\`bash
# Create .pre-commit-config.yaml
python3 plugins/attune/scripts/attune_init.py \\
  --lang python \\
  --name my-project \\
  --path

_meta.json

{
  "ownerId": "kn7d107jg9jv602h9ytsegydq184a42s",
  "slug": "nm-attune-precommit-setup",
  "version": "1.9.19",
  "publishedAt": 1787749612113
}

modules/ci-integration.md

---
name: ci-integration
description: GitHub Actions and GitLab CI workflow patterns mirroring local pre-commit checks.
parent: precommit-setup
load_when: configuring CI to run the same checks as pre-commit
---

# CI Integration

Verify CI runs the same comprehensive checks that pre-commit
runs locally. Drift between local hooks and CI is the most
common cause of "works on my machine" PRs.

## GitHub Actions

\`\`\`yaml
# .github/workflows/quality.yml
name: Code Quality

on: [push, pull_request]

jobs:
  quality:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Set up Python
        uses: actions/setup-python@v5
        with:
          python-version: '3.12'

      - name: Install uv
        run: pip install uv

      - name: Install dependencies
        run: uv sync

      - name: Run Comprehensive Quality Checks
        run: ./scripts/check-all-quality.sh

      - name: Upload Coverage
        uses: codecov/codecov-action@v4
        with:
          files: ./coverage.xml
\`\`\`

## Complete Example: Python Monorepo

\`\`\`yaml
# .pre-commit-config.yaml
repos:
  # Layer 1: Fast Global Checks
  - 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-toml
      - id: check-json

  - repo: https://github.com/astral-sh/ruff-pre-commit
    rev: v0.14.2
    hooks:
      - id: ruff
        args: [--fix]
      - id: ruff-format

  - repo: https://github.com/pre-commit/mirrors-mypy
    rev: v1.13.0
    hooks:
      - id: mypy
        args: [--ignore-missing-imports]

  - repo: https://github.com/PyCQA/bandit
    rev: 1.8.3
    hooks:
      - id: bandit
        args: [-c, pyproject.toml]

  # Layer 2: Component-Specific Checks
  - repo: local
    hooks:
      - id: run-component-lint
        name: Lint Changed Components
        entry: ./scripts/run-component-lint.sh
        language: system
        pass_filenames: false
        files: ^plugins/.*\\.py\$

      - id: run-component-typecheck
        name: Type Check Changed Components
        entry: ./scripts/run-component-typecheck.sh
        language: system
        pass_filenames: false
        files: ^plugins/.*\\.py\$

      - id: run-component-tests
        name: Test Changed Components
        entry: ./scripts/run-component-tests.sh
        language: system
        pass_filenames: false
        files: ^plugins/.*\\.(py|md)\$

  # Layer 3: Validation Hooks
  - repo: local
    hooks:
      - id: validate-plugin-structure
        name: Validate Plugin Structure
        entry: python3 scripts/validate_plugins.py
        language: system
        pass_filenames: false
        files: ^plugins/.*\$
\`\`\`

modules/component-level-hooks.md

---
name: component-level-hooks
description: Layer 2 per-component pre-commit checks for monorepos and plugin architectures.
parent: precommit-setup
load_when: project has multiple components or plugins
---

# Component-Specific Checks (Layer 2)

For monorepos, plugin architectures, or projects with multiple
components, add per-component quality checks. Each script
detects changed components from staged files and runs lint /
typecheck / test only against the affected components.

## Python Monorepo or Plugin Architecture

Create three quality-check scripts under `scripts/`. All three
share the same change-detection pattern.

### 1. Lint Changed Components (`scripts/run-component-lint.sh`)

\`\`\`bash
#!/bin/bash
# Lint only changed components based on staged files

set -euo pipefail

# Detect changed components from staged files
CHANGED_COMPONENTS=\$(git diff --cached --name-only | grep -E '^(plugins|components)/' | cut -d/ -f2 | sort -u) || true

if [ -z "\$CHANGED_COMPONENTS" ]; then
    echo "No components changed"
    exit 0
fi

echo "Linting changed components: \$CHANGED_COMPONENTS"

FAILED=()

for component in \$CHANGED_COMPONENTS; do
    if [ -d "plugins/\$component" ]; then
        echo "Linting \$component..."
        # Capture exit code to properly propagate failures
        local exit_code=0
        if [ -f "plugins/\$component/Makefile" ] && grep -q "^lint:" "plugins/\$component/Makefile"; then
            (cd "plugins/\$component" && make lint) || exit_code=\$?
        else
            (cd "plugins/\$component" && uv run ruff check .) || exit_code=\$?
        fi
        if [ "\$exit_code" -ne 0 ]; then
            FAILED+=("\$component")
        fi
    fi
done

if [ \${#FAILED[@]} -gt 0 ]; then
    echo "Lint failed for: \${FAILED[*]}"
    exit 1
fi
\`\`\`

### 2. Type Check Changed Components (`scripts/run-component-typecheck.sh`)

\`\`\`bash
#!/bin/bash
# Type check only changed components

set -euo pipefail

CHANGED_COMPONENTS=\$(git diff --cached --name-only | grep -E '^(plugins|components)/' | cut -d/ -f2 | sort -u) || true

if [ -z "\$CHANGED_COMPONENTS" ]; then
    exit 0
fi

echo "Type checking changed components: \$CHANGED_COMPONENTS"

FAILED=()

for component in \$CHANGED_COMPONENTS; do
    if [ -d "plugins/\$component" ]; then
        echo "Type checking \$component..."
        # Capture output and exit code separately to properly propagate failures
        local output
        local exit_code=0
        if [ -f "plugins/\$component/Makefile" ] && grep -q "^typecheck:" "plugins/\$component/Makefile"; then
            output=\$(cd "plugins/\$component" && make typecheck 2>&1) || exit_code=\$?
        else
            output=\$(cd "plugins/\$component" && uv run mypy src/ 2>&1) || exit_code=\$?
        fi
        # Display output (filter make noise)
        echo "\$output" | grep -v "^make\[" || true
        if [ "\$exit_code" -ne 0 ]; then
            FAILED+=("\$component")
        fi
    fi
done

if [ \${#FAILED[@]} -gt 0 

modules/standard-hooks.md

---
name: standard-hooks
description: Layer 1 fast global pre-commit checks for Python, Rust, and TypeScript projects.
parent: precommit-setup
load_when: configuring base linters
---

# Standard Hooks (Layer 1)

Fast global checks that run on every commit (typically 50-200ms total).

## Python Projects

### Basic Quality Checks

1. **pre-commit-hooks** -- file validation (trailing whitespace,
   EOF, YAML/TOML/JSON syntax)
2. **ruff** -- ultra-fast linting and formatting (~50ms)
3. **ruff-format** -- code formatting
4. **mypy** -- static type checking (~200ms)
5. **bandit** -- security scanning

### Configuration

\`\`\`yaml
# .pre-commit-config.yaml
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-toml
      - id: check-json

  - repo: https://github.com/astral-sh/ruff-pre-commit
    rev: v0.14.2
    hooks:
      - id: ruff
        args: [--fix]
      - id: ruff-format

  - repo: https://github.com/pre-commit/mirrors-mypy
    rev: v1.13.0
    hooks:
      - id: mypy
        args: [--ignore-missing-imports]

  - repo: https://github.com/PyCQA/bandit
    rev: 1.8.3
    hooks:
      - id: bandit
        args: [-c, pyproject.toml]
\`\`\`

## Rust Projects

1. **rustfmt** -- code formatting
2. **clippy** -- linting
3. **cargo-check** -- compilation check

## TypeScript Projects

1. **eslint** -- linting
2. **prettier** -- code formatting
3. **tsc** -- type checking

Sponsored

Ads related to precommit-setup and adjacent AI workflows.