run-in

SkillDev tools

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.

Available today. Use it from your connected AI after setup.

Connect ahel once, and every AI you use reads what you have installed.

Then ask your AI: use the run-in skill

What this skill tells your AI

The instructions your AI receives, as published by the-agency-ai/the-agency in .claude/skills/run-in/SKILL.md and read by ahel’s review.

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

  • You would otherwise write cd foo && bar && cd - — don't. Use run-in.
  • You need to run an Agency tool on another repo (e.g., agency verify on a downstream installation).
  • You need to run a git command on another worktree without leaving your shell parked in that worktree.
  • You want observability on the directory-scoped execution (log_start / 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

  • Hookify rule: agency/hookify/hookify.block-compound-bash.md
  • Tool: agency/tools/run-in
  • Companion seed: telemetry-mining for compound command patterns (flag #54)

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

Signals

GitHub stars
55
Forks
8
Last commit
Sep 2026
Advanced
Catalog kind
skill
Gateway key
run-in
Source
github.com/the-agency-ai/the-agency