Run in

From the-agency-ai/the-agency · View interactive version

Run in is an AI agent skill from the GitHub repository the-agency-ai/the-agency. Run a command in a target directory without touching the parent shell's CWD. Use any time you would write "cd foo && bar" — that pattern is blocked by the block-compound-bash hookify rule.

How to use this skill

Skill file

run-in

Run a command in a target directory via a subshell. The parent shell's CWD

is never touched. Exit code is propagated. Standard Agency telemetry.

When to use

a downstream installation).

shell parked in that worktree.

log_end are built in).

Signature

run-in <target-dir> -- <command> [args...]

The -- separator is required and distinguishes the target directory from

the command and its argv.

Examples

# Run a command on another repo without leaking CWD
./agency/tools/run-in ~/code/presence-detect -- ./agency/tools/agency verify

# Run a git command in a worktree from your captain shell
./agency/tools/run-in .claude/worktrees/devex -- git status

# Run a test suite in a sandbox dir
./agency/tools/run-in "$BATS_TEST_TMPDIR/mock" -- bats mock.bats

What NOT to do

# ❌ BLOCKED by hookify.block-compound-bash
cd ~/code/presence-detect && agency verify

# ❌ BLOCKED (parent shell CWD leaks)
cd .claude/worktrees/devex && git status && cd -

# ✅ Use run-in instead
./agency/tools/run-in ~/code/presence-detect -- agency verify
./agency/tools/run-in .claude/worktrees/devex -- git status

Why subshell isolation matters

Agent identity resolution uses the current working directory to determine

which agent is running (via agent-identity). If a worktree agent cds to

the main checkout and forgets to cd -, subsequent commands resolve the

wrong identity, handoffs write to the wrong file, and dispatches go to the

wrong agent. run-in runs the command in a subshell — the parent shell's

CWD is untouchable by construction, so identity resolution stays correct.

Related

OFFENDERS WILL BE FED TO THE — CUTE — ATTACK KITTENS!

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.