npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

configure-precommit

v1.0.4

Published

Agentic pre-commit setup - automatically configures pre-commit hooks for any repository using AI

Readme

configure-precommit

Automatically configure pre-commit hooks for any repository using AI-powered analysis.

Overview

This tool scans your repository, analyzes its structure and tech stack, and generates an optimal .pre-commit-config.yaml tailored to your project.

Supported stacks:

  • Python (ruff, mypy, bandit)
  • JavaScript/TypeScript (eslint, prettier)
  • Go (golangci-lint, go-fmt)
  • Java (pretty-format-java)
  • Terraform (terraform_fmt, tflint, checkov)
  • Docker (hadolint)
  • Shell (shellcheck)
  • Plus security scanning (gitleaks) and general hygiene hooks

Installation

# Using npx (no install required)
npx configure-precommit

# Or install globally
npm install -g configure-precommit

Quick Start

# 1. Set your API key
export ANTHROPIC_API_KEY="sk-ant-..."
# OR
export OPENAI_API_KEY="sk-..."

# 2. Run in your repository
cd /path/to/your/repo
configure-precommit

# Or specify a path
configure-precommit /path/to/your/repo

Requirements

  • macOS or Linux (Windows via WSL)
  • Node.js >= 14 (for npx/npm)
  • Git repository (initialized with git init)
  • API key - Anthropic (preferred) or OpenAI
  • System tools: git, jq, curl, python3

The script automatically installs pre-commit if not present.

How It Works

┌─────────────────────────────────────────────────────────────────┐
│  Phase 1: SENSOR                                                │
│  └── Scan repo structure, detect languages/frameworks           │
│                                                                 │
│  Phase 2: AUDITOR (LLM)                                         │
│  └── AI analyzes repo, generates optimal pre-commit config      │
│                                                                 │
│  Phase 3: BUILDER                                               │
│  ├── Write .pre-commit-config.yaml                              │
│  ├── Run pre-commit autoupdate (get latest versions)            │
│  └── Install git hooks                                          │
│                                                                 │
│  Phase 4: VERIFICATION & SELF-HEALING                           │
│  ├── Run pre-commit on all files                                │
│  └── If config errors → AI debugger fixes → retry (max 3x)      │
│                                                                 │
│  Phase 5: SUMMARY                                               │
│  └── Report installed hooks and any code issues found           │
└─────────────────────────────────────────────────────────────────┘

CLI Options

configure-precommit [OPTIONS] [REPO_PATH]

Options:
  -h, --help          Show help message
  -v, --version       Show version
  --dry-run           Generate config without installing hooks
  --skip-autoupdate   Skip running pre-commit autoupdate
  --debug             Enable debug output

Supported Hooks

| Category | Tools | Trigger | |----------|-------|---------| | Python | ruff, ruff-format, mypy, bandit | .py files | | JavaScript/TypeScript | eslint, prettier | .js, .ts, .jsx, .tsx | | Go | golangci-lint, go-fmt, go-imports | .go files | | Java | pretty-format-java | .java files | | Shell | shellcheck | .sh, .bash files | | Terraform | terraform_fmt, tflint, checkov | .tf files | | Docker | hadolint | Dockerfile | | YAML | yamllint, check-yaml | .yaml, .yml | | JSON | check-json | .json | | Security | gitleaks, detect-private-key | All files | | General | trailing-whitespace, end-of-file-fixer, check-merge-conflict, no-commit-to-branch | All files |

Environment Variables

| Variable | Description | |----------|-------------| | ANTHROPIC_API_KEY | Anthropic API key (preferred) | | OPENAI_API_KEY | OpenAI API key (fallback) | | PRECOMMIT_MAX_RETRIES | Max self-heal attempts (default: 3) | | PRECOMMIT_DRY_RUN | Generate config without installing | | PRECOMMIT_SKIP_AUTOUPDATE | Skip version auto-update | | DEBUG | Enable debug output |

Logging

All operations are logged to /tmp/precommit-setup/:

# View recent logs
ls -lt /tmp/precommit-setup/*.log | head -5

# Tail a running log
tail -f /tmp/precommit-setup/myrepo_*.log

Example Output

╔═══════════════════════════════════════════════════════════════╗
║            AGENTIC PRE-COMMIT SETUP                           ║
╚═══════════════════════════════════════════════════════════════╝

━━━━━━ PHASE 1: CONTEXTUAL SENSOR ━━━━━━
[INFO] Scanning repository structure...
[INFO] Found 47 files and 3 manifest files

━━━━━━ PHASE 2: AUDITOR (LLM Analysis) ━━━━━━
[INFO] Analyzing repository and generating configuration...
[INFO] Configuration generated successfully

━━━━━━ PHASE 3: BUILDER ━━━━━━
[INFO] Wrote configuration to .pre-commit-config.yaml
[INFO] Updating hook versions to latest...
[INFO] Git hooks installed successfully

━━━━━━ PHASE 4: VERIFICATION ━━━━━━
[INFO] All hooks passed successfully!

━━━━━━ PHASE 5: SUMMARY ━━━━━━

INSTALLED HOOKS:
  - gitleaks
  - ruff
  - ruff-format
  - shellcheck
  - check-yaml
  ...

[INFO] Setup complete!

Troubleshooting

"Not a git repository"

Initialize git first: git init

".pre-commit-config.yaml already exists"

Remove it first: rm .pre-commit-config.yaml

"No API key found"

Set one of:

export ANTHROPIC_API_KEY="sk-ant-..."
export OPENAI_API_KEY="sk-..."

Hooks fail due to missing tools

The debugger will automatically move those hooks to stages: [manual]. Install the tools later and run manually with pre-commit run <hook-id> --all-files.

File Structure

configure-precommit/
├── package.json              # npm package config
├── bin/
│   └── configure-precommit   # CLI entry point
├── setup-precommit.sh        # Main orchestration script
├── lib/
│   ├── logging.sh            # Logging utilities
│   ├── sensor.sh             # Repository scanning
│   ├── builder.sh            # Pre-commit installation
│   └── verifier.sh           # Verification loop
├── tests/
│   └── run_tests.sh          # Test suite
└── README.md

Development

# Clone the repo
git clone https://github.com/avivkaplan/configure-precommit.git
cd configure-precommit

# Run tests (requires API key)
./tests/run_tests.sh

# Lint shell scripts
shellcheck lib/*.sh bin/configure-precommit setup-precommit.sh

License

MIT