EXEC

A project rule saying that shell commands must run through agentsh, which executes them in a sandboxed session.

In plain words
What is it for?
Use it for any terminal command, including installing dependencies, running tests, building the project, or invoking scripts.
Why use it?
It enforces the codebase's command-execution policy and keeps commands within the expected environment.

Cursor rule

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add rules/canyonroad/agentsh/exec
Clone the repo
git clone --depth 1 https://github.com/canyonroad/agentsh
Per session 377 This file is loaded in full into every session.
When invoked 377 The same file — it is already loaded in full.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00377 $0.00377
Opus 5 $0.00188 $0.00188
Sonnet 5 $0.00075 $0.00075
Haiku 4.5 $0.00038 $0.00038

Measured 2d ago against content hash b722341ea9f2, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

EXEC scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

examples/cursor/EXEC.mdc · 56 lines

What it actually says

agentsh Command Execution

When executing shell commands in this codebase, use agentsh to run commands within a sandboxed session.

Syntax for Single Command Execution

Basic Form

agentsh exec SESSION_ID -- COMMAND [ARGS...]

The -- separator is required between the session ID and the command.

Examples

agentsh exec my-session -- ls -la
agentsh exec my-session -- npm install
agentsh exec my-session -- go build ./...

With Environment Variable (Preferred for Agents)

When AGENTSH_SESSION_ID is set, all arguments after exec become the command:
export AGENTSH_SESSION_ID=my-session
agentsh exec -- ls -la
agentsh exec -- npm install

Auto-Create Session on First Exec

If the session doesn't exist, use --root to auto-create it:
agentsh exec my-session --root /path/to/workspace -- ls -la

Or set AGENTSH_SESSION_ROOT:
export AGENTSH_SESSION_ROOT=/path/to/workspace
agentsh exec my-session -- ls -la

Common Flags

| Flag          | Description                                    |
|---------------|------------------------------------------------|
| --timeout 30s | Command timeout (e.g., 30s, 5m)                |
| --output json | JSON structured output instead of shell output |
| --stream      | Stream output as it's produced                 |
| --pty         | Interactive PTY mode                           |

Environment Variables

| Variable             | Description                                    |
|----------------------|------------------------------------------------|
| AGENTSH_SESSION_ID   | Session ID to use (avoids passing as argument) |
| AGENTSH_SESSION_ROOT | Root directory for auto-creating sessions      |
| AGENTSH_SERVER       | Server URL (default: http://127.0.0.1:18080)    |
Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 56 lines · 377 tokens per session scan A b722341ea9f2

Subscribe to this mod's changes

EXEC is a cursor rule published in the GitHub repository canyonroad/agentsh (378 stars, last pushed 26d ago), licensed Apache-2.0. It adds 377 tokens to every session, about $0.0019 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.