Skip to content

feat: /freeze skill — restrict file edits to a scoped directory #6

Description

@josephfung

Idea

Add a /freeze skill that activates a PreToolUse hook on Edit and Write tool calls, hard-blocking any file modifications outside a declared directory. The scope is set by writing a path to ~/.trimkit/freeze-dir.txt and cleared when the skill is deactivated.

Goal

When debugging or investigating a specific part of a codebase, accidental edits to unrelated files are a real risk — especially when Claude is running autonomously. /freeze enforces scope discipline: you declare where work should happen, and edits outside that boundary are denied.

Example workflow

/freeze src/auth/
# Claude is now restricted to editing files under src/auth/
# Any Edit or Write call outside that path is hard-blocked with a clear message

/freeze off
# Scope restriction lifted

Implementation approach

  1. Add skills/freeze/SKILL.md — skill prompt that:
    • On activation: resolves the given path (handling symlinks via pwd -P), writes it to ~/.claude/sysops/freeze-dir.txt, confirms to user
    • On deactivation (/freeze off): removes ~/.claude/sysops/freeze-dir.txt
  2. Add hooks/check-freeze.shPreToolUse hook on Edit and Write tools that:
    • Reads ~/.claude/sysops/freeze-dir.txt (if file doesn't exist, allows everything)
    • Resolves the target file path and checks if it falls within the freeze boundary
    • Returns {"permissionDecision":"deny","message":"Edit blocked: outside freeze boundary (<path>). Run /freeze off to lift restriction."} if outside
  3. Register the hook in settings/hooks.json scoped to the skill
  4. Update install.sh accordingly

Notes

  • Hard-block (deny), not warn-and-confirm — scope violations are never intentional during a freeze
  • Gracefully allows everything when freeze-dir.txt doesn't exist (no-op when skill is inactive)
  • Pairs naturally with debugging workflows: activate before starting, deactivate when done
  • Could later be extended to support multiple allowed paths

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions