One security policy, compiled into the native permission and sandbox
configuration of every AI coding agent you run.
Contents
- Why twsrt
- How it works — three pictures
- Use cases at a glance
- Install and quickstart
- Configuration
- Per-project policy
- Agents
- Verifying the policy
- Security at a glance
- Commands
- Documentation map · Development
Why twsrt
Claude Code, Codex and Copilot CLI each have their own permission model and
config format. Maintaining "never read ~/.aws, never run sudo, only reach
github.com" three times by hand drifts and leaves gaps. twsrt keeps that
policy once and compiles it into every agent:
┌───────────────────────────┐
you edit ───► │ policy fragments (JSONC) │ never read ~/.aws · never run sudo
│ + profiles (config.toml) │ only reach github.com · ask before git push
└─────────────┬─────────────┘
│ twsrt generate -w
┌──────────────┬─────┴────────┬────────────────┐
▼ ▼ ▼ ▼
~/.srt-settings Claude Code Codex Copilot CLI + JetBrains
(SRT sandbox) settings.json config.toml settings.json, flags,
+ .rules github-copilot.xml
How it works
Three ideas explain the whole tool.
1. One policy, compiled in two stages
stage 1: compile — depends on the profile only
───────────────────────────────────────────────────────────────────────
fragments ─(profile)─► compose ─► canonical config (in memory)
├─ srt ──► ~/.srt-settings.json ──► read by SRT
└─ bash ──► bash-rules.json
│
▼ parse
normalized rules + sandbox/network/filesystem config
│
stage 2: translate — agent argument picks which generators run
───────────────────────────────────────────────────────────────────────
┌──────────────────────────┼──────────────────────────┐
▼ ▼ ▼
Claude generator Codex generator Copilot generators
settings.json config.toml + .rules settings.json + flags,
github-copilot.xml
twsrt show prints stage 1 generate <agent> prints stage 2
generate <agent> -w writes stage 1 (all of it) + stage 2 (that agent)
The canonical config is the input for every agent translation.
~/.srt-settings.json and bash-rules.json are the compiled policy of one
profile: the single source of truth. SRT reads ~/.srt-settings.json
directly; every agent config is translated from the same compile. These
paths assume output = "~/.srt-settings.json"; an omitted output writes
srt-settings.json next to config.toml, which srt reads only via
srt -s (config.toml).
|
Canonical config |
Agent configs |
| Files |
~/.srt-settings.json, bash-rules.json |
Claude settings.json, Codex config.toml + .rules, Copilot settings.json + flags, JetBrains github-copilot.xml |
| Role |
Source of truth; SRT enforcement file |
Lossy translations into each agent's native model |
| Depends on |
Profile only |
Canonical config + agent |
| Inspect |
twsrt show [srt\|bash] |
twsrt generate <agent> |
| Written by |
every generate -w, whichever agent is selected |
generate <that agent> -w |
Consequences:
twsrt generate copilot -w writes ~/.srt-settings.json. The agent argument only selects
which translations run.
- Never hand-edit generated files. ; the next
generate -w overwrites a hand edit, and twsrt diff reports it as drift. Edit the fragments (twsrt edit) instead.
- Nothing is written unless everything compiles. A conflict between fragments fails fast.
2. Two enforcement layers
The same policy is enforced twice, by two different mechanisms:
agent (Node, Rust, …)
┌───────────────────────────────────────────────────────────────┐
│ built-in tools: Read · Edit · WebFetch ◄── layer 2 only │
│ │ │
│ layer 2: agent permissions (deny / ask / allow, all tools) │
│ │ │
│ └─► Bash tool ──spawns──┐ │
└────────────────────────────────┼──────────────────────────────┘
▼
┌───────────────────────────────────────────────────────────────┐
│ layer 1: kernel sandbox (Seatbelt / bubblewrap + net proxy) │
│ every spawned command: deny paths, write allowlist, domains │
└───────────────────────────────────────────────────────────────┘
| Access |
Layer 1: kernel sandbox |
Layer 2: agent permissions |
Bash(cat ~/.aws/credentials) |
denied |
denied |
Read(~/.aws/credentials) |
not covered (in-process) |
denied |
Bash(curl evil.com) |
proxy blocks |
denied |
WebFetch(evil.com) |
not covered (in-process) |
allow check |
Bash(git push) vs Bash(ls) |
cannot tell them apart |
deny / ask per command |
The kernel layer (deny paths, write allowlist, allowed domains) is the
durable core and translates with high fidelity into every agent. The Bash
deny/ask rules are a per-agent supplement. Why both are needed:
SECURITY_CONCEPT.md.
3. Profiles choose which fragments are active
A fragment is one slice of policy. A profile is a combination of fragments.
Profiles extend each other but only ever add:
fragment pool (the policy)
profile │ srt/base srt/cloud-creds srt/work bash/base │ typical use
─────────┼────────────────────────────────────────────────┼───────────────────────────
default │ ● ● ● │ the global files
work │ ● ● ● ● │ extends default, adds work
slim │ ● ● │ one repo, via --project
- Children add, they never override. A scalar the parent sets cannot be
changed by a child; that is a compile error, so no profile can silently
weaken another.
- One profile is in force at a time for the global files:
generate -w -p work and generate -w write the same files and the last run wins.
- A project can drop a rule by choosing a profile without that fragment,
compiled into a project repository instead of the global files — see
Per-project policy.
Use cases at a glance
| I want to … |
Run |
More |
| Start from scratch |
twsrt config --init |
Quickstart |
| Change the policy |
twsrt edit → twsrt generate -w <agent> |
Configuration |
| See what an agent would get, without writing |
twsrt generate <agent> |
Agents |
| See the compiled sandbox file |
twsrt show |
How it works |
| Run an agent with fewer prompts, or with nobody present |
The agent's own launch flag; the policy stays the same |
Prompting |
| Use a different policy set on this machine |
twsrt generate -w -p work <agent> |
Profiles |
| Relax one rule for one repository only |
twsrt generate claude -w -p slim --project |
Per-project policy |
| Check nobody edited generated files |
twsrt diff |
Verifying |
| Prove the sandbox actually blocks what the policy says |
twsrt test |
Verifying |
| Find redundant rules and pattern traps |
twsrt doctor |
Verifying |
Install and quickstart
uv tool install twsrt # or: pip install twsrt
twsrt config --init # writes ~/.config/twsrt/config.toml + starter fragments
twsrt edit # opens every fragment: deny paths, domains, command rules
twsrt config # enable agents: [targets] claude_settings = "~/.claude/settings.json"
twsrt show # print the compiled canonical srt settings
twsrt generate claude # preview the Claude translation and the files -w would write
twsrt generate claude -w # write the canonical outputs + ~/.claude/settings.json
twsrt diff # exit 0 when every target matches the fragments
twsrt test # prove the sandbox enforces the policy (plain terminal)
A common launch pattern regenerates the policy on every start:
c() { twsrt generate -w claude && claude "$@"; }
Prompting is a launch choice
twsrt compiles what is denied and what asks. Who answers an ask rule is
decided per session, with the agent's own flag, and never changes a generated
file (ADR 0010). The sandbox
settings are the same in every case.
|
Fewer prompts, ask rules still ask |
Nobody present, ask rules deny |
| Claude Code |
--permission-mode auto (or bypassPermissions) |
--permission-mode dontAsk, or --settings '{"permissions":{"denyInsteadOfPrompting":true}}' (keeps auto mode) |
| Copilot CLI |
--allow-all-tools; deny rules still win |
-p or --autopilot: what would prompt is denied |
| Codex |
-c approvals_reviewer=auto_review |
-a never |
Traps. codex --yolo removes the sandbox. copilot --yolo also drops the
path and URL checks, and Copilot's in-process file tools are checked in
software only. claude --allow-dangerously-skip-permissions skips nothing by
itself, it only makes that mode selectable.
Keep ask for commands whose effect leaves the sandbox (remote systems,
published history, new dependencies). Files, secrets and domains are enforced by
the kernel however a command is spelled; Bash rules match the command text only.
To let a set of commands run without asking, put their ask rules in a fragment
of their own and choose a profile
without it.
Configuration
Only config.toml and the .jsonc fragments are edited by hand. Relative
paths resolve from the directory containing config.toml; ~ and absolute
paths also work. twsrt config --init writes a fully commented version.
Every compile write-denies config.toml and every [sources] path (outputs
and fragments), so a sandboxed agent cannot loosen its own policy: edit them
from a plain terminal
(why).
| Term |
Meaning |
| Source kind |
A canonical document type: srt (filesystem and network policy, required) and bash (command allow/ask/deny lists, optional) |
| Fragment |
One named .jsonc file holding a slice of policy for one source kind. Fragments never include each other |
| Profile |
An ordered selection of fragments per source kind; may extend other profiles. default_profile applies when -p is omitted |
| Target |
An agent config file translated from the canonical output |
config.toml
schema_version = 1
default_profile = "default"
# --- canonical sources: one compiled output, one or more fragments each ---
[sources.srt]
output = "~/.srt-settings.json" # optional, see below
[sources.srt.fragments.base]
path = "srt/base.jsonc"
[sources.srt.fragments.work]
path = "srt/work.jsonc"
[sources.bash] # optional; output omitted: bash-rules.json next to config.toml
[sources.bash.fragments.base]
path = "bash/base.jsonc"
# --- profiles: fragment selections; children add, they never override ---
[profiles.default]
srt = ["base"]
bash = ["base"]
[profiles.work]
extends = ["default"]
srt = ["work"]
# --- targets: agents are opt-in; an unset key means "agent not configured" ---
[targets]
claude_settings = "~/.claude/settings.json" # the file Claude Code reads
codex_config = "~/.codex/config.toml"
codex_rules = "~/.codex/rules/twsrt.rules" # optional, needs codex_config: escalation rules
copilot_settings = "~/.copilot/settings.json" # Copilot CLI native sandbox (ADR 0009)
copilot_output = "~/.config/twsrt/copilot-flags.txt" # optional, independent of copilot_settings
copilot_jetbrains_xml = [ # one file per JetBrains product and version
"~/Library/Application Support/JetBrains/IntelliJIdea2026.2/options/github-copilot.xml",
]