Skip to main content
OrchestKit v6.7.1 — 67 skills, 38 agents, 77 hooks with Opus 4.6 support
OrchestKit

File Guard

Protects sensitive files and enforces file size limits on writes

Blocks Global

Prevents modification of sensitive files (secrets, keys, credentials) and blocks oversized source files to enforce modular code structure.

When It Fires

Event: PreToolUse · Matcher: Write, Edit · Bundle: pretool.mjs

What It Does

File guard serves two purposes: security enforcement and code quality gating.

For every Write or Edit operation, the hook resolves the target file path --- including following symlinks to prevent bypass attacks (ME-001 security fix) --- and checks it against a blocklist of protected file patterns. If the file matches, the operation is denied outright.

For Write operations on code files, the hook also enforces maximum line counts and detects structural bloat patterns. Files that exceed the line limit are blocked with a message suggesting how to split them. Files under the limit but showing multiple bloat signals get a warning logged (non-blocking).

Protected Paths

These file patterns are always blocked --- Claude cannot write to them:

PatternWhat It Protects
.env, .env.local, .env.productionEnvironment variables and secrets
credentials.json, secrets.jsonApplication credentials
.pem, private.keyTLS/SSL certificates
id_rsa, id_ed25519SSH private keys

File Size Limits

File TypeDefault LimitEnvironment Variable
Source files (.py, .ts, .tsx, .js, .jsx, .go, .rs, .java)300 linesORCHESTKIT_MAX_FILE_LINES
Test files (*.test.*, *.spec.*, test_*, *_test.*)500 linesORCHESTKIT_MAX_TEST_FILE_LINES

Bloat Detection

When writing code files, the hook scans for structural problems:

  • God file --- more than 15 exports in a single file
  • Mixed concerns --- types and logic in the same file (over 150 lines)
  • High coupling --- more than 20 imports
  • Multi-class --- multiple class declarations in one file
  • Multi-component --- more than 3 component declarations in one file

Files over the line limit with bloat signals get a detailed denial message listing each detected pattern.

Configuration

Override file size limits with environment variables:

# Allow larger source files (default: 300)
ORCHESTKIT_MAX_FILE_LINES=500

# Allow larger test files (default: 500)
ORCHESTKIT_MAX_TEST_FILE_LINES=800

Config files (package.json, pyproject.toml, tsconfig.json) trigger a logged warning but are not blocked.

Edit on GitHub

Last updated on