New:Introducing Socket Scanning for VS Code Marketplace Extensions.Learn more →
Get Started

configure-precommit

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

configure-precommit

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

Source
npmnpm
Version
1.0.3
Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

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

CategoryToolsTrigger
Pythonruff, ruff-format, mypy, bandit.py files
JavaScript/TypeScripteslint, prettier.js, .ts, .jsx, .tsx
Gogolangci-lint, go-fmt, go-imports.go files
Javapretty-format-java.java files
Shellshellcheck.sh, .bash files
Terraformterraform_fmt, tflint, checkov.tf files
DockerhadolintDockerfile
YAMLyamllint, check-yaml.yaml, .yml
JSONcheck-json.json
Securitygitleaks, detect-private-keyAll files
Generaltrailing-whitespace, end-of-file-fixer, check-merge-conflict, no-commit-to-branchAll files

Environment Variables

VariableDescription
ANTHROPIC_API_KEYAnthropic API key (preferred)
OPENAI_API_KEYOpenAI API key (fallback)
PRECOMMIT_MAX_RETRIESMax self-heal attempts (default: 3)
PRECOMMIT_DRY_RUNGenerate config without installing
PRECOMMIT_SKIP_AUTOUPDATESkip version auto-update
DEBUGEnable 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

Keywords

pre-commit

FAQs

Package last updated on 24 Jan 2026

Related posts