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

ai-fs-permissions

v1.0.0

Published

CLI tool to enforce file system permissions for AI agents. Protects sensitive files and folders from unauthorized access.

Readme

ai-fs-permissions

A platform-agnostic security tool that enforces file system permissions for AI agents. Designed to protect sensitive files and folders from unauthorized access by AI coding assistants.

Why?

When using AI coding assistants like Claude Code, Gemini CLI, or Cursor, you might want to:

  • Protect configuration folders (.centy, .claude, .github)
  • Make certain files read-only (lock files, configs)
  • Block access to sensitive files (.env, secrets, keys)
  • Allow read but block write to specific paths

This package provides a CLI that can enforce these permissions, working with any AI tool that supports command hooks.

Installation

pnpm add -g ai-fs-permissions

Or use without installation via pnpm dlx ai-fs-permissions or npx ai-fs-permissions.

Quick Start

# Check if writing to .centy is allowed
ai-fs-permissions --op write --path ".centy/config.json"
# Exit code: 2 (blocked if configured)

# Check if reading is allowed
ai-fs-permissions --op read --path "src/index.ts"
# Exit code: 0 (allowed)

# Show current configuration
ai-fs-permissions --show-config

Configuration

Create .ai-fs-permissions.yaml in your project root:

version: 1

rules:
  # Protect centy configuration (read-only)
  - path: ".centy/**"
    access: read
    reason: "Configuration folder - modifications may break tooling"

  # Protect AI agent settings
  - path: ".claude/**"
    access: read
    reason: "AI agent settings - must be modified by user only"

  # Block all access to env files
  - path: "**/.env*"
    access: none
    reason: "Environment secrets - sensitive data"

  # Block key files using regex
  - path: "^.*\\.key$"
    type: regex
    access: none
    reason: "Key files contain sensitive credentials"

  # Allow specific file within protected folder (negation)
  - path: "!.centy/user-config.yaml"
    access: readwrite
    reason: "User-editable config"

Access Levels

| Level | Read | Write | Description | |-------|------|-------|-------------| | none | Blocked | Blocked | Fully blocked | | read | Allowed | Blocked | Read-only | | write | Blocked | Allowed | Write-only (rare) | | readwrite | Allowed | Allowed | Full access |

Config Discovery

Configs are discovered gitignore-style and merged:

  1. ~/.config/ai-fs-permissions/config.yaml (user defaults)
  2. Walk up from cwd to find .ai-fs-permissions.yaml (project)
  3. ./.ai-fs-permissions.yaml (current directory, highest priority)

Set extends: false in project config to ignore user defaults.

Platform Integration

Claude Code

Add to your .claude/settings.json:

{
  "hooks": {
    "PreToolUse": [
      {
        "matcher": "Read|Glob|Grep",
        "hooks": [
          {
            "type": "command",
            "command": "npx ai-fs-permissions --op read"
          }
        ]
      },
      {
        "matcher": "Edit|Write|NotebookEdit",
        "hooks": [
          {
            "type": "command",
            "command": "npx ai-fs-permissions --op write"
          }
        ]
      }
    ]
  }
}

Gemini CLI

Add to your .gemini/settings.json:

{
  "hooks": {
    "BeforeTool": [
      {
        "matcher": "read_file",
        "hooks": [
          {
            "type": "command",
            "command": "npx ai-fs-permissions --op read"
          }
        ]
      },
      {
        "matcher": "write_file|edit_file",
        "hooks": [
          {
            "type": "command",
            "command": "npx ai-fs-permissions --op write"
          }
        ]
      }
    ]
  }
}

Cursor

Create .cursor/hooks.json:

{
  "version": 1,
  "hooks": {
    "beforeShellExecution": [
      {
        "command": "npx ai-fs-permissions --op write"
      }
    ]
  }
}

CLI Options

ai-fs-permissions [options] [path]

Options:
  --op <type>       Operation to check: read, write (required)
  --path <path>     File path to check
  --config <path>   Use specific config file (skip discovery)
  --show-config     Show merged configuration and exit
  --validate        Validate config file and exit
  --help, -h        Show help message
  --version, -v     Show version

Input Methods:
  1. Command line:  ai-fs-permissions --op write --path ".centy/config.json"
  2. Stdin (JSON):  echo '{"tool_input":{"file_path":"..."}}' | ai-fs-permissions --op write
  3. Stdin (plain): echo ".centy/config.json" | ai-fs-permissions --op write

Exit Codes

  • 0 - Operation allowed
  • 2 - Operation blocked
  • 1 - Error occurred

Blocked Message

When an operation is blocked, a clear message is output to guide the AI agent:

PERMISSION DENIED: Writing to '.centy/settings.json' is blocked.

Reason: Configuration folder - modifications may break tooling

This rule is configured by the project owner and cannot be overridden.
Do NOT attempt to:
- Use Bash commands to bypass this restriction
- Suggest workarounds that modify this path
- Ask the user to disable this protection

If this file must be modified, ask the user to do it manually.

License

MIT

Related Projects