Bibliothèque › Mods

Automatisme (hook)

Enforcement du mode lecture seule subagent

Force les subagents à être en lecture seule en bloquant les modifications de fichiers.

Comment l'utiliser

Dans Claude Code, lance ces commandes :

npx claude-code-templates@latest --hook security/subagent-read-only-guard

Ouvrir le dépôt d'origine

Le contenu

Le contenu est réservé aux abonnés

Compris dans SuperPrompt : copiez, téléchargez et installez toutes les fiches, avec les six agents métier x10. 7 jours gratuits, puis 97 € par an, résiliable en trois clics.

Description d'origine, en anglais

Enforces read-only subagents. A PreToolUse hook denies Edit, Write, MultiEdit, NotebookEdit and PowerShell, and any Bash or Monitor command that is not read-only, when the call comes from a subagent (detected by the agent_id field Claude Code adds only inside subagents; tested on Claude Code 2.1.296). Shell commands pass only when every command is a bare program from a short read-only allowlist (ls, cat, grep, rg, find, jq, sort, sed -n 'N,Mp', cd, git log/diff/status/show/blame/branch/tag and similar) without the options that make it write or run other programs, including abbreviated long options. Redirection to files, command substitution, shell expansion ($VAR, {a,b}), subshells, env-var prefixes, git -c and anything the guard cannot classify are denied, including its own errors. The main conversation is never affected. Not covered: MCP tools, and git diff/blame running diff or textconv drivers already configured in the repo. Reading secrets (.env, printenv) is still allowed, so pair it with env-file-protection. Pairs with the hooks/subagents-explore-only setting, which tells subagents up front that they are exploration-only.

D'où vient cette fiche

Création de davila7, publiée sur davila7/claude-code-templates sous licence MIT.

Le contenu est reproduit tel quel, dans le respect de sa licence. Le titre, le résumé et le classement en français sont rédigés par SuperPrompt.