Skip to content
youdede

Workspace boundary guard

SecurityHookv1.0.0

A bounded Claude Code PreToolUse hook for Write, Edit, MultiEdit, and NotebookEdit that checks lexical containment and the canonical location of the nearest existing ancestor before allowing a file mutation.

Runs on

Scope
$npx @youdede/toolkit add workspace-boundary-guard --target claude-code

What it does

Block native file edits whose resolved target escapes the active project workspace.

When it fires

  • implementation
  • operations

How it behaves

Verify lexical and canonical containment for native file mutation targets without modifying the filesystem.

It does not expand the workspace boundary from a repository file, tool payload, or agent-authored exception.

It does not follow a symlink chain whose canonical existing ancestor escapes the workspace.

It does not claim to replace operating-system sandboxing or prevent a filesystem race after evaluation.

Configuration

targets/claude-code/workspace-boundary-guard.mjsnode · read-only

Version
1.0.0
Requires
node
Licence
RiskThis automatic gate blocks native file edits whose resolved target escapes the active project workspace; a false denial can interrupt legitimate work, but it does not execute the blocked action.
Medium
ModeHow it works: fixed rules, model instructions, or both.
Deterministic only
Behaviour
Enforces, blocks on violation
On failure
Denies and blocks
LatencyThe entrypoint handles one intercepted event to block native file edits whose resolved target escapes the active project workspace without deferred work.
Immediate
Data retentionWhether data remains after use and who manages its storage.
Not retained

Often used with

All in Security