agentleFS
LuisHiluyLuisHiluy/claude-code-pipeline-skills/lockscenes/SKILL.md

lockscenes

Skill0 starsChanged 7 months agoMITView on GitHub

On-demand write protection for approved files during final assembly, implemented via Claude Code PreToolUse hooks — a rare working example of hook-based file guards. Use when the user enters a final-assembly phase, wants to freeze approved work, or says "lock scenes", "protect these files", "freeze approved", "/lockscenes", "add a write guard", or asks how to temporarily block edits during a critical phase. Trigger this skill whenever the user needs temporary, scoped file-level guards without restructuring the repo.

The file

We split this skill into the rules it gives an agent

6 rules. About 0 are common, 1 is distinctive, and 5 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 5

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    When invoked, Claude creates a lock file at runs/.scene_lock with patterns to protect.

    line 44
  2. Distinctive:

    If the target file path matches any pattern, the edit is denied.

    line 70
  3. Very specific:

    When /lockscenes is invoked:

    line 75
  4. Very specific:

    If "unlock": delete runs/.scene_lock and confirm

    line 78
  5. Very specific:

    If no arguments: write default lock patterns to .scene_lock

    line 79
  6. Very specific:

    If item IDs given: write those IDs as patterns to .scene_lock

    line 80

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Lock Scenes — On-Demand Write Protection

Blocks Edit/Write to approved files during final assembly. Only active when invoked via /lockscenes. The hook is removed when the session ends.

This is a rare example of Claude Code's PreToolUse hooks used for on-demand file guards. Useful pattern for any project that has an "approved" or "frozen" state.

Usage

Lock default set (everything approved)

/lockscenes

This writes a lock file and activates the PreToolUse hook. Any attempt to Edit or Write a file matching a locked pattern is denied.

Lock specific items

/lockscenes shot-01 shot-02 cut-01

Unlock (remove all locks)

/lockscenes unlock

What Gets Locked

When invoked, Claude creates a lock file at runs/.scene_lock with patterns to protect.

Default lock (no arguments) — protect common approved paths:

review_data.json
cleaned_prompts.json
references/approved/
scene_bundles/

Customize the defaults in scripts/guard-approved.sh for your project.

Item-specific lock — add IDs as patterns:

shot-01
shot-02
cut-01

How It Works

  1. You invoke /lockscenes. The skill activates for this session.
  2. Claude Code runs the hook script (guard-approved.sh) before every Edit/Write.
  3. The script reads runs/.scene_lock for locked patterns.
  4. If the target file path matches any pattern, the edit is denied.
  5. Claude sees the denial message and skips that file.

Implementation Steps (for Claude)

When /lockscenes is invoked:

  1. Parse arguments — specific item IDs or "unlock"
  2. If "unlock": delete runs/.scene_lock and confirm
  3. If no arguments: write default lock patterns to .scene_lock
  4. If item IDs given: write those IDs as patterns to .scene_lock
  5. Confirm: "Locked N patterns. Edit/Write to matching files will be blocked this session."

Gotchas

  • The lock file is just a text file with patterns, one per line. Lines starting with # are comments.
  • The hook only blocks Edit and Write tools. Bash commands like sed or echo > are NOT blocked. This is intentional — if you need to force-edit, you can, but you have to be deliberate.
  • The lock persists in the file system, but the hook only runs while the skill is active. Stale lock files are harmless but should be cleaned up.
  • The lock file should live in a gitignored path (e.g., runs/), not in the repo.

Why this pattern matters

Claude Code hooks are powerful but underused. This skill shows a real production use:

  • On-demand activation (not always-on — flips on only during final assembly)
  • Scoped to a specific tool matcher (Edit|Write)
  • Uses a simple text file as state
  • Zero dependencies beyond bash

Fork the pattern for any lifecycle stage where you need temporary guards.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.