agentleFS
EtanHeyEtanHey/golems/skills/golem-powers/heredoc-guard/SKILL.md

heredoc-guard

Skill0 starsChanged 16 days agoApache-2.0View on GitHub

Deny command substitution in unquoted shell heredocs before execution.

The file

We split this skill into the rules it gives an agent

1 rule. About 0 are common, 0 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

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

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

    If a value must expand, compute it first: put v=$(cmd) on its own line before the heredoc, then use $v in the unquoted body.

    line 11

≈ “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

Heredoc guard

Unquoted heredocs (<<EOF, <<-EOF) expand backticks and $(command) in their bodies. A backticked command in generated Markdown can run on the host. Quote the delimiter: <<'EOF', <<"EOF", <<\EOF, or <<E"OF". If a value must expand, compute it first: put v=$(cmd) on its own line before the heredoc, then use $v in the unquoted body. Quoting preserves literal text; precomputing preserves the intended computed value. Escaped backticks/dollars, variable expansion and arithmetic alone are allowed. There is no environment bypass. Commands without a heredoc operator return allow before shell inspection; << split by escaped newlines still counts. Invalid or unsupported syntax and inspection limits in heredoc-bearing commands deny with a plain refusal; the ledger keeps the stage and short cause. ANSI-C escapes in delimiters require a plain quoted rewrite; ordinary ANSI-C quoted arguments are treated as strings.

Scope: inspect the outer shell command, including executable substitutions. Quoted interpreter payloads such as bash -c '…' are strings and are not recursively interpreted. Quotes inside an unquoted heredoc body do not protect it. This is a heredoc guard, not a full shell syntax validator.

Claude uses the fail-closed launcher; Codex uses codex-policy-hook.py. Codex uses the standard ^(Bash|apply_patch)$ matcher. The gate immediately allows non-Bash events; native patch content is never parsed as shell. Each denial appends one JSONL record to the heredoc guard ledger in the user's Claude logs directory, following tmp-block's durable logs convention. Override the destination with HEREDOC_GUARD_LEDGER; tests and probes use isolated ledgers. Records contain ts, command_sha256, rule, and a short static reason, never raw command text. Missing or invalid commands use the SHA-256 of the empty string. An unwritable ledger still denies with the same plain refusal. Source wiring does not prove installed/native enforcement. Installation and native acceptance belong to the lead after merge; this change installs nothing.

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.