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

claude-hooks-setup

v1.0.1

Published

Automatically setup Claude Code hooks and settings configuration

Readme

Claude Hooks Setup

🚀 Automatically setup Claude Code with intelligent git hooks and configuration for seamless AI-powered development workflow.

✨ Features

  • Intelligent Commit Messages: Automatically generates git commit messages from your Claude assistant interactions
  • Zero Configuration: One command setup - finds your .claude directory automatically
  • Cross-Platform: Works on macOS, Windows, and Linux
  • Smart Text Processing: Cleans up commit messages by removing unnecessary punctuation and formatting
  • Git Integration: Only commits when there are actual changes and you're in a git repository
  • Safe Operations: Includes safeguards to prevent commit loops and errors

🚀 Quick Start

Installation

npm install -g claude-hooks-setup

Setup

claude-hooks-setup

That's it! The tool will:

  1. 🔍 Find your Claude Code configuration directory
  2. 📝 Create/update the stop hook for automatic commits
  3. ⚙️ Configure your settings.json with recommended settings
  4. ✅ Validate the setup

📋 How It Works

Automatic Commit Messages

When you finish an interaction with Claude Code, the hook will:

  1. Extract the last assistant message from your session
  2. Clean the text by removing unnecessary formatting (stars, extra commas, etc.)
  3. Generate a commit message with format: feat: [cleaned message content]
  4. Commit your changes automatically (only if you're in a git repo with changes)

Example

If Claude's last message was:

已优化 `testBasicSetters` 方法,**主要改进包括:**
1. **配置化测试数据** - 使用 `testConfig` 对象集中管理测试参数
2. **详细日志记录** - 每个设置操作都有独立的成功日志

The generated commit message will be:

feat: 已优化 testBasicSetters 方法,主要改进包括: 1. 配置化测试数据 - 使用 testConfig 对象集中管理测试参数 2. 详细日志记录 - 每个设置操作都有独立的成功日志

🔧 Configuration

The tool automatically configures your Claude Code settings.json with:

{
  "hooks": {
    "Stop": [
      {
        "hooks": [
          {
            "type": "command",
            "command": "node ~/.claude/hooks/auto-commit-hook.js"
          }
        ]
      }
    ]
  },
  "editor": {
    "auto_save": true,
    "format_on_save": true
  },
  "git": {
    "auto_commit": true,
    "commit_on_stop": true
  },
  "ui": {
    "show_token_count": true,
    "confirm_before_exit": false
  },
  "logging": {
    "level": "info",
    "enable_hooks_logging": true
  }
}

📁 Directory Structure

After setup, your .claude directory will look like:

~/.claude/
├── settings.json          # Claude Code configuration
├── hooks/
│   └── auto-commit-hook.js  # Auto-commit hook
└── ... (other Claude files)

🛠️ Manual Configuration

If you prefer manual setup or need to customize:

Find Your Claude Directory

The tool searches for .claude in these locations:

macOS:

  • ~/.claude
  • ~/Library/Application Support/Claude
  • ~/Library/Application Support/claude

Windows:

  • %APPDATA%\\Claude
  • %APPDATA%\\claude
  • %LOCALAPPDATA%\\Claude
  • %LOCALAPPDATA%\\claude

Linux:

  • ~/.claude
  • ~/.config/claude
  • ~/.local/share/claude

Environment Variable

Set CLAUDE_CONFIG_PATH to specify a custom location:

export CLAUDE_CONFIG_PATH=/path/to/your/claude/config
claude-hooks-setup

🔄 Upgrading

To update to the latest version:

npm update -g claude-hooks-setup
claude-hooks-setup  # Re-run to update hooks

🚫 Disabling

To temporarily disable auto-commits, edit your settings.json:

{
  "hooks": {
    "Stop": []
  }
}

Or remove the specific hook object from the Stop array.

🐛 Troubleshooting

Hook Not Triggering

  1. Check Claude Code restart: Restart Claude Code after setup
  2. Verify settings: Ensure settings.json has the correct hook path
  3. Check permissions: Ensure the hook file is executable (Unix systems)

Commit Issues

  1. Git repository: The hook only works in git repositories
  2. Git configuration: Ensure git user name/email are configured
  3. File changes: The hook only commits when there are actual changes

Directory Not Found

  1. Manual path: Use CLAUDE_CONFIG_PATH environment variable
  2. Create manually: Create ~/.claude directory if needed
  3. Permissions: Ensure you have write access to the directory

📝 CLI Options

claude-hooks-setup --help     # Show help
claude-hooks-setup --version  # Show version

🤝 Contributing

Contributions are welcome! Please feel free to submit issues and pull requests.

Development Setup

git clone https://github.com/xzj-abc/claude-hooks-setup.git
cd claude-hooks-setup
npm install
npm link  # For local testing

📄 License

MIT License - see LICENSE file for details.

🔗 Related


Made with ❤️ for the Claude Code community