Submodule target guard
A deterministic Claude Code PreToolUse gate that reconstructs .gitmodules changes and inspects static submodule-add commands, blocking new relative URLs, local paths, insecure transports, branch tracking, or dynamic targets.
Runs on
What it does
Reject newly introduced Git submodules with relative, mutable, local, or insecure targets.
When it fires
- implementation
- pre-commit
- maintenance
How it behaves
Validate bounded submodule configuration and commands before introducing mutable or unsafe repository targets.
It does not clone, fetch, initialize, update, remove, or approve a Git submodule.
It does not contact a remote or prove that a permitted remote repository is trustworthy.
It does not infer a safe target from shell variables, command substitution, aliases, or prompt text.
It does not expose a repository-owned bypass list for submodule destinations.
Configuration
targets/claude-code/submodule-target-guard.mjs
- Version
- 1.0.0
- Requires
- Shell command guard
- Licence
- RiskThis automatic gate rejects newly introduced Git submodules with relative, mutable, local, or insecure targets; 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 reject newly introduced Git submodules with relative, mutable, local, or insecure targets without deferred work.
- Immediate
- Data retentionWhether data remains after use and who manages its storage.
- Not retained
Often used with
All in Security