Claude Code hook
Claude Ignore
A Claude Code PreToolUse hook that prevents Claude from reading files that match patterns in .claudeignore files, similar to how .gitignore works.
Install
npm install -g claudeignoreFound in the project README. Check it for setup steps after installing.
git clone https://github.com/li-zhixin/claude-ignore.gitFrom the README
claude-ignore A Claude Code PreToolUse hook that prevents Claude from reading files that match patterns in .claudeignore files, similar to how .gitignore works. 中文说明 / Chinese Documentation Features - Hierarchical .claudeignore support: Automatically discovers and applies .claudeignore files from the current directory up to the root - Supports standard gitignore-style patterns - Works as a Claude Code PreToolUse hook - Exits with code 2 when a path is ignored, preventing Claude from reading the file - Filters out comments (lines starting with #) and empty lines - Flexible project configuration with multiple ignore levels Installation Install globally to use across all projects: To update to the latest version: Quick Start Option 1: Auto Setup (Recommended) Run the init command in your project directory: This will: - Create a .claudeignore file if it doesn't exist - Set up .claude/settings.json with the necessary hook configuration - If .claude/settings.json already exists, it will show you the template configuration for manual merging Option 2: Manual Setup 1. Create a .claudeignore file in your project root with patterns to ignore: 2. Configure Claude Code to use this as a PreToolUse hook by adding to .claude/settings.json: Commands claude-ignore init Initializes claude-ignore configuration in your project: - Creates .claudeignore file from template if it doesn't exist - Creates .claude/settings.json with hook configuration if it doesn't exist - Shows template configuration for manual merging if .claude/settings.json already exists claude-ignore (default) Checks if a file should be ignored based on .claudeignore patterns. This is used internally by Claude Code as a PreToolUse hook. How it works When Claude tries to read a file, this hook: 1.…
How hooks work
- Hooks are shell commands Claude Code runs at fixed points: before or after a tool call, when you submit a prompt, when Claude stops, on notifications and at session start.
- They are set in the hooks section of ~/.claude/settings.json (or .claude/settings.json for a project), or come bundled in a plugin.
- A hook can block a tool call, add context, or run a formatter or test. Read the scripts before you install them: they run on your machine with your permissions.
Details
- Repository
- li-zhixin/claude-ignore
- Type
- Hooks
- Language
- JavaScript
- License
- MIT
- Last updated
- 5 November 2025
- Topics
- claudeclaude-codeignore
FAQ
What is Claude Ignore?
A Claude Code PreToolUse hook that prevents Claude from reading files that match patterns in .claudeignore files, similar to how .gitignore works. It is a hook for Claude Code, from li-zhixin/claude-ignore on GitHub.
How do I install Claude Ignore?
Run npm install -g claudeignore, then follow the setup in the README.
Is Claude Ignore popular?
li-zhixin/claude-ignore has 47 GitHub stars and 8 forks. It was last updated on 5 November 2025.
More hooks
Jev Axi
46shiftynick/jev-axi
Agent-ergonomic CLI for TypeSafe's Jev: fast calibrated judgments (pick, rate, check, rank, triage, guard) from the shell
Claude Agent Builder
46keysersoose/claude-agent-builder
Build production-ready AI agents in Claude Code from natural language. Analyzes your problem, researches best practices, and generates subagents, skills, hooks, commands & MCP configs.
Claude Code Zero
53LeeJuOh/claude-code-zero
Complete Claude Code plugin marketplace — agents, skills, hooks, commands, rules, MCPs.
Claude Code Prompt Optimizer
490-to-1-Labs/claude-code-prompt-optimizer
AI-powered prompt optimization hook for Claude Code. Transforms simple prompts into comprehensive, structured instructions using Claude Opus 4.6's advanced reasoning capabilities.
agent-guard
38JeongJaeSoon/agent-guard
Secret-leak guardrails for Claude Code and Codex, also usable as git hooks and in CI.
claude-code-toast
18eyalzh/claude-code-toast
macOS Notification hook that shows a toast when Claude Code is waiting for you.
Browse the most popular Claude Code mods, all hooks, or the skills and MCP server directories.