Claude-ignore is a pre-tool-use hook that prevents Claude from reading files matching patterns in .claudeignore files. It benefits developers and operations teams by controlling file access, similar to .gitignore. It integrates with Claude Code and is useful for managing sensitive or irrelevant files in automated workflows.
git clone https://github.com/li-zhixin/claude-ignore.gitClaude-ignore is a PreToolUse hook for Claude Code that prevents Claude from reading files matching patterns defined in .claudeignore files, similar to how .gitignore works in Git. It discovers and applies ignore patterns hierarchically, starting from the current directory up through parent directories, allowing flexible configuration across different project levels. When Claude attempts to read a file, the hook checks against all discovered patterns and blocks access if there's a match, exiting with code 2 to prevent the read operation. This tool is designed for developers and operations teams who need to control access to sensitive files, environment variables, secrets, or irrelevant project files during automated workflows. Setup is straightforward using the init command or manual configuration in .claude/settings.json.
1. **Locate or create a `.claudeignore` file** in your project root or specified directory. Add patterns to exclude files (e.g., `node_modules/`, `.env*`, `build/`). 2. **Run claude-ignore** in your terminal or within Claude Code to verify ignored files. Use the command: `claude-ignore --list [DIRECTORY_PATH]` to list ignored files. 3. **Cross-check exclusions** by manually reviewing the output against your `.claudeignore` rules. Ensure no critical files are unintentionally excluded. 4. **Integrate with workflows** by adding claude-ignore to your CI/CD pipeline or automated scripts to ensure consistent file access control. 5. **Update patterns** in `.claudeignore` as your project evolves. Test changes by re-running claude-ignore to confirm new exclusions work as intended.
Prevent Claude from accessing .env files and API keys during code analysis
Block reads of sensitive configuration or credential files in automated workflows
Exclude large or irrelevant directories from Claude's file access to improve efficiency
Maintain different ignore rules across subdirectories within a single project
No install command available. Check the GitHub repository for manual installation instructions.
git clone https://github.com/li-zhixin/claude-ignoreCopy the install command above and run it in your terminal.
Launch Claude Code, Cursor, or your preferred AI coding agent.
Use the prompt template or examples below to test the skill.
Adapt the skill to your specific use case and workflow.
Use claude-ignore to exclude files matching patterns in [.claudeignore_PATH]. List all files in [DIRECTORY_PATH] that would be ignored by claude-ignore. For each ignored file, provide its path and reason for exclusion based on the .claudeignore rules. Example: 'Exclude node_modules/ due to node_modules/ in .claudeignore'
Here are the files that would be ignored by claude-ignore in the project directory `/home/user/project`, based on the rules in `.claudeignore` located at `/home/user/project/.claudeignore`: 1. **`/home/user/project/node_modules/react-dom/server.js`** - Excluded due to pattern `node_modules/` in `.claudeignore`. - Reason: This file is part of a dependency directory and is not relevant for code analysis. 2. **`/home/user/project/.env.local`** - Excluded due to pattern `.env*` in `.claudeignore`. - Reason: This file contains sensitive environment variables and should not be accessed. 3. **`/home/user/project/build/output.log`** - Excluded due to pattern `build/output.log` in `.claudeignore`. - Reason: This file is a generated log and not part of the source code. 4. **`/home/user/project/temp/cache/12345.json`** - Excluded due to pattern `temp/` in `.claudeignore`. - Reason: This file is part of a temporary cache directory and is not needed for analysis. 5. **`/home/user/project/docs/legacy/README_old.md`** - Excluded due to pattern `docs/legacy/` in `.claudeignore`. - Reason: This file is part of an outdated documentation directory. Total files ignored: 5 Total files accessible: 42
AI assistant built for thoughtful, nuanced conversation
Agents that listen, think and act for you.
Auto-transcribe meetings and generate action items
Build custom sales tools fast
Enterprise workflow automation and service management platform
Automate your spreadsheet tasks with AI power
Take a free 3-minute scan and get personalized AI skill recommendations.
Take free scan