agentignore
Policy-Filtered Filesystem for AI Agents.
agentignore is a FUSE filesystem that provides a filtered virtual view of a real directory tree. Files and directories matching rules in a .agentignore file are completely hidden from processes interacting with the mounted filesystem — they don't appear in ls, find, glob expansion, or direct access.
The primary use case is constraining autonomous AI/LLM agents that have shell access, so irrelevant files and directories (node_modules/, .git/, target/, .env, secrets/, etc.) genuinely appear non-existent to the agent while still allowing the agent to execute build and test tools.
All visible files behave as a transparent passthrough: reads and writes go directly to the real filesystem.
Note: This is not a security boundary. AgentIgnore is designed to reduce LLM context by hiding irrelevant files, not to prevent a determined attacker from accessing them.
Table of Contents
Quick Start
Install via your favorite package manager:
# npm
# pnpm
# bun
# run it
Install via crate:
Or build from source with Cargo:
# 1. Ensure FUSE is available (see Prerequisites below)
# 2. Build the binary
# 3. Create example policy files in your project
# 4. Start a shell inside the filtered view
Prerequisites for Running
AgentIgnore needs the FUSE kernel module and libfuse3 on the host. Setup differs slightly across environments.
Linux (bare-metal)
# Ubuntu / Debian
# Fedora / RHEL
# Arch
# Load the kernel module (usually auto-loads on access, but this guarantees it)
# Verify
No additional configuration needed — run the binary directly.
Docker / Dev Container
When running inside a container, FUSE support must be explicitly granted at container creation time:
For VS Code Dev Containers, add to .devcontainer/devcontainer.json:
Why
SYS_ADMIN? Themount(2)syscall (which FUSE uses internally) requiresCAP_SYS_ADMINinside a container. The--device /dev/fuseflag exposes the kernel FUSE interface.
Inside the container, libfuse3 is usually preinstalled. If not:
&&
WSL2
WSL2 supports FUSE out of the box with recent kernels:
# Install fuse3 inside your WSL distribution (Ubuntu example)
# Load the module
Known issue: Custom WSL2 kernels built before Linux 5.4 may lack FUSE support. Run
uname -rto check your kernel version. If FUSE is unavailable, update your WSL kernel viawsl --updatefrom a Windows PowerShell.
Usage
init — create policy files
Creates .agentignore and .agentallow files in a directory:
run — mount, execute, unmount
Mount a filtered view, run a command inside it, and unmount automatically:
# Run bash inside a filtered view of the current directory
# Run a specific tool with arguments
# Run from a specific source directory
explain — debug visibility
Check whether a path would be hidden and why:
# HIDDEN
# canonical path: "/project/.env"
# matched rule: .env
# VISIBLE
# canonical path: "/project/src/main.rs"
Policy Files
.agentignore
Uses standard gitignore pattern syntax. Files matching these patterns are hidden from the agent.
# secrets
.env
*.pem
*.key
# hidden directories
secrets/
node_modules/
# recursive patterns
**/*.tfstate
# negations (exceptions)
!important.env
.agentallow
Process-based bypass rules. Processes matching entries in this file can see hidden files — useful for development tools that need full access.
Example use case: The agent should not "see" files within node_modules but if it launch npm run build, the tool needs these files to build the app.
One entry per line. Empty lines and lines starting with # are ignored (comments).
Process name / cmdline matching
| Syntax | Behaviour |
|---|---|
^npm run |
Regex matched against the process comm name or its full cmdline; also checks ancestor processes (parent, grandparent, etc.). |
=npm |
Exact match against comm or cmdline; ancestors are also checked. |
=bash! |
Exact match, no ancestor walk — matches only the exact process. |
node! |
Regex, no ancestor walk — matches only the exact process. |
Binary path matching (entry starts with /)
| Syntax | Behaviour |
|---|---|
/usr/bin/node |
Literal path; matches process or any ancestor. |
/usr/bin/java! |
Literal path; matches only that exact process. |
# Allow npm and its children to see everything (regex, walks ancestors)
npm
# Allow only the exact 'restic backup' command (exact match, no ancestor walk)
=restic backup!
# Allow the exact bash process, not commands run inside it (exact, no ancestor walk)
=bash!
# Allow any java process or its children (regex, walks ancestors)
java
# Allow a specific binary and everything under it (literal path, walks ancestors)
/usr/bin/git
# Allow only that exact binary path (literal path, no ancestor walk)
/usr/bin/git!
Building from Source
Build prerequisites
See https://rust-lang.org/tools/install/ how to prepare rust dev environmet or use the provided devcontainer in this repo.
Build commands
# Fast type-check during development
# Debug build
# Optimized release build
# Run with cargo
# Run tests
# Run linter and formatter before committing
Development
Or you can create one yourself. See docs/project.md for a one-shot prompt to re-create the project.