New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

scope-locker

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

scope-locker

PreToolUse hook that enforces filesystem permissions per project

latest
npmnpm
Version
0.1.1
Version published
Maintainers
1
Created
Source

scope-lock

PreToolUse hook for Claude Code that enforces filesystem permissions per project. Define which files the agent can read and write in a manifest — everything else is denied.

Install

npm install -g scope-lock

Setup

  • Create .scope-lock.json in your project root:
{
  "allow": {
    "read": ["src/**", "package.json", "README.md", "tsconfig.json", "*.config.*"],
    "write": ["src/**"]
  },
  "deny": [".env*", "node_modules/**", ".git/**", "**/secrets/**"]
}
  • Add to ~/.claude/settings.json:
{
  "hooks": {
    "PreToolUse": [
      {
        "matcher": "Read|Write|Edit|Glob|Grep|Bash",
        "hooks": [
          {
            "type": "command",
            "command": "scope-lock",
            "timeout": 5
          }
        ]
      }
    ]
  }
}

How It Works

  • Claude wants to call a tool (Read, Write, Edit, Bash, etc.)
  • The hook intercepts the call and extracts file paths from the tool input
  • Paths are matched against your manifest's allow/deny rules
  • Deny rules take precedence over allow rules
  • Paths matching no rule are denied by default
  • Exit 0 = allow, Exit 2 = deny with reason

Manifest Format

Supports both .scope-lock.json and .scope-lock.yaml:

JSON:

{
  "allow": {
    "read": ["src/**", "docs/**", "*.md"],
    "write": ["src/**"]
  },
  "deny": [".env*", ".git/**", "node_modules/**"]
}

YAML:

allow:
  read:
    - src/**
    - docs/**
    - "*.md"
  write:
    - src/**
deny:
  - .env*
  - .git/**
  - node_modules/**

Glob Patterns

  • * — matches any characters except /
  • ** — matches any characters including / (recursive)
  • ? — matches a single character
  • .env* — matches .env, .env.local, .env.production
  • src/** — matches everything under src/

Tool Path Extraction

ToolPath Source
Read, Write, Edittool_input.file_path
Globtool_input.path (default: .)
Greptool_input.path (default: .)
BashBest-effort regex extraction from command

Requirements

  • Node.js >= 22
  • ESM only

License

MIT

FAQs

Package last updated on 22 Mar 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts