Configure comprehensive three-layer pre-commit quality system with linting, type checking, and testing enforcement
/plugin marketplace add athola/claude-night-market/plugin install attune@claude-night-marketThis skill inherits all available tools. When active, it can use any tool Claude has access to.
scripts/run-component-lint.sh)scripts/run-component-typecheck.sh)scripts/run-component-tests.sh)scripts/check-all-quality.shConfigure a comprehensive three-layer pre-commit quality system that enforces linting, type checking, and testing before commits.
This skill implements a comprehensive quality system based on three layers:
Key Principle: New code is automatically checked before commit, preventing technical debt from entering the repository.
```yaml
repos:
repo: https://github.com/pre-commit/pre-commit-hooks rev: v6.0.0 hooks:
repo: https://github.com/astral-sh/ruff-pre-commit rev: v0.14.2 hooks:
repo: https://github.com/pre-commit/mirrors-mypy rev: v1.13.0 hooks:
repo: https://github.com/PyCQA/bandit rev: 1.8.0 hooks:
For monorepos, plugin architectures, or projects with multiple components, add per-component quality checks.
Create quality check scripts:
scripts/run-component-lint.sh)```bash #!/bin/bash
set -e
CHANGED_COMPONENTS=$(git diff --cached --name-only | grep -E '^(plugins|components)/' | cut -d/ -f2 | sort -u)
if [ -z "$CHANGED_COMPONENTS" ]; then echo "No components changed" exit 0 fi
echo "Linting changed components: $CHANGED_COMPONENTS"
for component in $CHANGED_COMPONENTS; do if [ -d "plugins/$component" ]; then echo "Linting $component..." cd "plugins/$component" if [ -f "Makefile" ] && grep -q "^lint:" Makefile; then make lint else uv run ruff check . fi cd ../.. fi done ```
scripts/run-component-typecheck.sh)```bash #!/bin/bash
set -e
CHANGED_COMPONENTS=$(git diff --cached --name-only | grep -E '^(plugins|components)/' | cut -d/ -f2 | sort -u)
if [ -z "$CHANGED_COMPONENTS" ]; then exit 0 fi
echo "Type checking changed components: $CHANGED_COMPONENTS"
for component in $CHANGED_COMPONENTS; do if [ -d "plugins/$component" ]; then echo "Type checking $component..." cd "plugins/$component" if [ -f "Makefile" ] && grep -q "^typecheck:" Makefile; then make typecheck else uv run mypy src/ fi cd ../.. fi done ```
scripts/run-component-tests.sh)```bash #!/bin/bash
set -e
CHANGED_COMPONENTS=$(git diff --cached --name-only | grep -E '^(plugins|components)/' | cut -d/ -f2 | sort -u)
if [ -z "$CHANGED_COMPONENTS" ]; then exit 0 fi
echo "Testing changed components: $CHANGED_COMPONENTS"
for component in $CHANGED_COMPONENTS; do if [ -d "plugins/$component" ]; then echo "Testing $component..." cd "plugins/$component" if [ -f "Makefile" ] && grep -q "^test:" Makefile; then make test else uv run pytest tests/ fi cd ../.. fi done ```
```yaml
id: run-component-lint name: Lint Changed Components entry: ./scripts/run-component-lint.sh language: system pass_filenames: false files: ^(plugins|components)/.*\.py$
id: run-component-typecheck name: Type Check Changed Components entry: ./scripts/run-component-typecheck.sh language: system pass_filenames: false files: ^(plugins|components)/.*\.py$
id: run-component-tests name: Test Changed Components entry: ./scripts/run-component-tests.sh language: system pass_filenames: false files: ^(plugins|components)/.*\.(py|md)$ ```
Add custom validation hooks for project-specific requirements.
```yaml
```bash
python3 plugins/attune/scripts/attune_init.py \ --lang python \ --name my-project \ --path .
mkdir -p scripts chmod +x scripts/run-component-*.sh ```
Create pyproject.toml with strict type checking:
```toml [tool.mypy] python_version = "3.12" warn_return_any = true warn_unused_configs = true disallow_untyped_defs = true strict = true
[[tool.mypy.overrides]] module = "plugins.*" strict = true ```
```toml [tool.pytest.ini_options] testpaths = ["tests"] pythonpath = ["src"] addopts = [ "-v", # Verbose output "--strict-markers", # Strict marker enforcement "--cov=src", # Coverage for src/ "--cov-report=term", # Terminal coverage report ]
markers = [ "slow: marks tests as slow (deselect with '-m \"not slow\"')", "integration: marks tests as integration tests", ] ```
```bash
uv sync --extra dev
uv run pre-commit install
uv run pre-commit run --all-files
git add . git commit -m "feat: add feature"
```
For comprehensive quality checks (CI/CD, monthly audits):
scripts/check-all-quality.sh```bash #!/bin/bash
set -e
echo "=== Running Comprehensive Quality Checks ==="
./scripts/run-component-lint.sh --all
./scripts/run-component-typecheck.sh --all
./scripts/run-component-tests.sh --all
echo "=== ✓ All Quality Checks Passed ===" ```
Pre-commit hooks run in this order:
```
All must pass for commit to succeed.
| Check | Single Component | Multiple Components | All Components |
|---|---|---|---|
| Global Ruff | ~50ms | ~200ms | ~500ms |
| Global Mypy | ~200ms | ~500ms | ~1s |
| Component Lint | ~2-5s | ~4-10s | ~30-60s |
| Component Typecheck | ~3-8s | ~6-16s | ~60-120s |
| Component Tests | ~5-15s | ~10-30s | ~120-180s |
| Total | ~10-30s | ~20-60s | ~2-5min |
--incremental flag```bash
SKIP=run-component-tests git commit -m "WIP: tests in progress"
SKIP=run-component-lint,run-component-typecheck,run-component-tests git commit -m "WIP"
git commit --no-verify -m "Emergency fix" ```
Add project-specific hooks:
```yaml
id: check-architecture name: Validate Architecture Decisions entry: python3 scripts/check_architecture.py language: system pass_filenames: false files: ^(plugins|src)/.*\.py$
id: check-coverage name: Ensure Test Coverage entry: python3 scripts/check_coverage.py language: system pass_filenames: false files: ^(plugins|src)/.*\.py$ ```
Ensure CI runs the same comprehensive checks:
```yaml
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
```
Solution: Only changed components are checked by default. For even faster commits:
```bash
SKIP=run-component-tests git commit -m "WIP: feature development"
./scripts/run-component-tests.sh --changed ```
```bash
uv run pre-commit clean
find . -name "pycache" -type d -exec rm -rf {} + find . -name ".pytest_cache" -type d -exec rm -rf {} + find . -name ".mypy_cache" -type d -exec rm -rf {} + ```
```bash
uv run pre-commit run --verbose --all-files
cd plugins/my-component make lint make typecheck make test ```
```toml
[tool.pytest.ini_options] pythonpath = ["src"] ```
```toml
[[tool.mypy.overrides]] module = "legacy_module.*" disallow_untyped_defs = false ```
strict = true in tool.mypy--no-verify sparingly - Only for true emergenciespyproject.toml for common settings```yaml
repos:
repo: https://github.com/pre-commit/pre-commit-hooks rev: v6.0.0 hooks:
repo: https://github.com/astral-sh/ruff-pre-commit rev: v0.14.2 hooks:
repo: https://github.com/pre-commit/mirrors-mypy rev: v1.13.0 hooks:
repo: https://github.com/PyCQA/bandit rev: 1.8.0 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)$
Skill(attune:project-init) - Full project initializationSkill(attune:workflow-setup) - GitHub Actions setupSkill(attune:makefile-generation) - Generate component MakefilesThis skill should be used when the user asks to "create an agent", "add an agent", "write a subagent", "agent frontmatter", "when to use description", "agent examples", "agent tools", "agent colors", "autonomous agent", or needs guidance on agent structure, system prompts, triggering conditions, or agent development best practices for Claude Code plugins.
This skill should be used when the user asks to "create a slash command", "add a command", "write a custom command", "define command arguments", "use command frontmatter", "organize commands", "create command with file references", "interactive command", "use AskUserQuestion in command", or needs guidance on slash command structure, YAML frontmatter fields, dynamic arguments, bash execution in commands, user interaction patterns, or command development best practices for Claude Code.
This skill should be used when the user asks to "create a hook", "add a PreToolUse/PostToolUse/Stop hook", "validate tool use", "implement prompt-based hooks", "use ${CLAUDE_PLUGIN_ROOT}", "set up event-driven automation", "block dangerous commands", or mentions hook events (PreToolUse, PostToolUse, Stop, SubagentStop, SessionStart, SessionEnd, UserPromptSubmit, PreCompact, Notification). Provides comprehensive guidance for creating and implementing Claude Code plugin hooks with focus on advanced prompt-based hooks API.