A first profile
After this page you will know what a Box profile is, where it lives, what packs and starters are, and what box run does when you press Enter. You will write the profile by hand, one setting at a time, until Claude Code starts inside a box. The story needs it now because every later act, from b1 to c, runs on this one profile, grown a little on each page.
Your files at this point
No Box profile exists yet. The only file you have is the MCP configuration you wrote during set-up, in your workspace.
{ "mcpServers": { "cloudflare": { "type": "http", "url": "https://mcp.cloudflare.com/mcp", "headers": { "Authorization": "Bearer ${CLOUDFLARE_MCP_TOKEN}" } } }}Text description of the diagram
Stage 2 of 5.
Pieces in the picture:
- the macOS keychain, which holds the three secrets; the developer reads them into shell variables
- the developer's terminal
- Claude Code, the agent
- the contained filesystem view: only the paths the profile grants exist for the agent (new at this stage)
- the box CLI and Box Core, which build the box and run its trusted process (new at this stage)
- stand-in secrets: the agent gets placeholders, the real values stay in the trusted process (new at this stage)
- the egress gateway, which every network request from the box goes through (new at this stage)
- the Anthropic API
- Cloudflare's MCP server
- the Cloudflare API
- the sample app: the Worker box-poc-workshop with its D1 database, KV namespace and Workers Logs; the logs and the database hold attendee names and email addresses
- Boundaries: the box, agent's sandbox, trusted process.
The picture is the one from the previous page: the box, the agent’s sandbox inside it, and the trusted process with the box CLI and Box Core, the stand-in secrets and the egress gateway. This page builds two of those pieces in practice: the box CLI and Box Core, which you drive with box run, and the contained filesystem view, which your profile decides.
The words this page uses
Section titled “The words this page uses”Five words come up on every Box page. Here is each one, once, with the folder it lives in. In output on this site your home folder is written as ~; Box prints the full path.
- Box home. The folder where the box CLI keeps everything it writes. You set it in set-up with
BOX_HOME="$HOME/box-ws". Without it, Box uses~/.strands/box. - Profile. One file,
profile.toml, that says how the box is set up for one agent: what runs, what it may reach, which secrets it gets, and which policy files apply. It lives in$BOX_HOME/profiles/<name>/. The Box docs put it this way: a profile “names packs for the details and holds only your choices”. - Pack. A reusable piece of profile, kept in its own
pack.toml. A pack “holds what one program needs in a box: how to start it, where its settings are, and which hosts it reaches”. Box ships packs named@box/<name>. A profile lists the packs it uses, and Box merges them in order, with the profile last. - Storage. The folders the agent keeps between runs, in
$BOX_HOME/storage/<profile>/default/agent/. Claude Code’s settings and sessions will live here, not in your own~/.claude. - Run. One
box run. Each run gets its own box, an ID such asb-e4d0f0dc5f9bfc35, and a run folder$BOX_HOME/r/<box ID>/with the files Box generated for that run and its records.
At the end of this page your Box home looks like this:
Directorybox-ws/
Directoryprofiles/
Directoryws/
- profile.toml the file you write on this page
Directorystorage/
Directoryws/
Directorydefault/
Directoryagent/
Directoryconfig/ Claude Code’s own configuration, kept between runs
- …
Directorytmp/ Claude Code’s temporary folder
- …
Directoryr/
Directoryb-<16 hex>/ one folder per run
- box.toml Box Core’s configuration, generated from the profile
- policy.dw the run’s rules, generated
- profile-name
- records.jsonl the run’s records
Directorybox/ Box Core’s state for the run
- …
The run folder layout is from the Box docs (docs/cli/files.md) and was checked by listing a run folder on this build.
Read moreHow Box works: profiles, packs and the boxBox docs
Read moreWhere Box keeps its filesBox docs
Packs and starters, and why we write the profile by hand
Section titled “Packs and starters, and why we write the profile by hand”A starter is the list of questions box profile create asks. Your answers become a profile, and “the profile never refers to the starter again”. Box ships three starters: claude, codex and kiro.
The claude starter builds on the pack @box/claude. That pack runs Claude Code well, and it does one thing this workshop cannot accept: at the first run it copies parts of your own ~/.claude into the box’s storage. Some copies can be switched off (skills, settings, app state, memory, some variables). Others cannot: CLAUDE.md, rules, commands, agents, output styles, themes and keybindings are copied with no switch to turn them off (source: resources/packs/claude/README.md and pack.toml).
This workshop never lets your Claude Code configuration into a box. Every act runs Claude Code with an empty configuration, so the numbers compare and nothing personal leaks into a run. So we do not use the starter or @box/claude. We write the profile by hand. That is also the best way to learn what each line does.
A profile that imports ~/.claude brings in whatever hooks, rules and MCP settings a developer has collected. A hand-written profile holds only what you can read on one screen.
The shipped pack is the quick start for daily use. Here you give that up to see every setting the pack would have made for you.
What we do. Before writing anything, ask Box what it has.
What this doesLists your profiles and the starters Box ships.
box profile listlist$BOX_HOME/profiles with its packs, then the starters. It changes nothing.What we see. No profiles yet, and the three starters.
box: Profiles
No profiles in ~/box-ws/profiles. Create one from a starter: `box profile create <starter>`.Starters: claude Claude Code codex Codex kiro Kiro CLICould box profile create make a profile without the claude starter? Try it with only the Anthropic pack:
What this doesAsks Box to create a profile named ws from one pack and the locked policy starter.
box profile create ws --with @box/anthropic --policy lockedws$BOX_HOME/profiles/ws/. We use a short name because you type it in every command.--with @box/anthropic@box/anthropic is the shipped pack that declares the route to the Anthropic API. The @box/ prefix matters: without it, Box looks for a pack of your own named anthropic and fails with the pack "anthropic" does not exist.--policy lockedlocked gives the project read-only access and permits almost nothing. Without the flag and without a terminal, Box stops and asks which policy to use.What we see. Box refuses, and writes nothing (exit 1).
box: error: ~/box-ws/profiles/ws/profile.toml: no pack runs an agent; name an agent pack with `--with`, or name the profile after a starter (`box profile list` lists them)Read moreStartersBox docs
Read moreProfilesBox docs
Read moreThe @box/claude pack and what it importsBox docs
What we add. The profile’s folder, and an empty profile.toml in it.
What this doesCreates the profile's folder in your Box home.
mkdir -p "$BOX_HOME/profiles/ws"-p"$BOX_HOME/profiles/ws"Now create the file $BOX_HOME/profiles/ws/profile.toml in your editor and leave it empty. Then ask Box what it makes of it:
What this doesResolves the profile for the current folder and prints what a run would get. It starts no box.
box profile show wswsWhat we see.
box: error: ~/box-ws/profiles/ws/profile.toml: missing field `agent`A profile must say what runs. box profile show is the check you run after every change: it reads the profile and its packs, fills in the placeholders, checks the policy as box run would, and prints the result. It starts nothing and writes no run files.
What we add. The [agent] table: the program Box starts inside the box.
[agent]command = ["${{ home }}/.local/bin/claude", { slot = "agent-args" }][agent]is the agent’s table. Everything about the program the box runs goes in it or in its sub-tables.commandis a list of arguments, not a line of shell text. Box runs the first element as the program, with the others as its arguments. Nothing is expanded by a shell.${{ home }}is a Box placeholder for your home folder. Box fills it in when it resolves the profile.~/.local/bin/claudeis where Claude Code’s native installer puts its link.{ slot = "agent-args" }marks where extra arguments go: everything you type after--onbox runis placed here.
The run. Start the box and ask Claude Code only for its version.
What this doesRuns the profile ws in the current folder and passes --version to Claude Code.
box run ws --no-banner -- --versionrun wsws. The folder you are in (~/leaderboard-ops) becomes the run’s project.--no-banner--box’s own options. Everything after it goes to Claude Code unchanged, at the agent-args slot.--versionWhat we see (shortened where marked with ...):
box: profile ws gives the agent no access to this project; to allow it, add `[project] access = "write"` to ~/box-ws/profiles/ws/profile.tomlbox: running profile ws with box ID b-e4d0f0dc5f9bfc35 (records: ~/box-ws/r/b-e4d0f0dc5f9bfc35/records.jsonl)box: to reuse this box run: box run ws --box-id b-e4d0f0dc5f9bfc35box: policy history: box runs history b-e4d0f0dc5f9bfc35strands-box: box b-e4d0f0dc5f9bfc35 created · config ~/box-ws/r/b-e4d0f0dc5f9bfc35/box.tomlstrands-box: starting workloadstrands-box: [agent] runs ~/.local/share/claude/versions/2.1.330 with no policy decision over these paths: (no filesystem entry) exec ~/.local/share/claude/versions/2.1.330 (command, implicit)strands-box: [agent] runtime minimum, added by Core: read /usr/share/icu ... /System/Library ... /dev/null ... enter ~/leaderboard-ops (workspace, entry only)strands-box: [agent] HOME=~ PATH=~/box-ws/r/b-.../box/bin:<the whole PATH of your shell>2.1.330 (Claude Code)Your box ID will differ: every run gets a new one. Read the output from the top:
- Lines starting
box:come from the box CLI. It found the profile, made a run with a new box ID, and told you where the records are and how to read the run’s decisions later. - Lines starting
strands-box:come from Box Core, the engine the CLI starts. Its startup report says what the agent’s process can reach without a policy decision: here, only the right to execute its own binary. Core adds a runtime minimum of system paths every program needs, and the right to enter the project folder, but not to read it. - The last line is Claude Code itself, running inside the box.
Note what was not needed: a read grant on the binary. The old launcher of this kit granted it; this build ran Claude Code without one.
Read moreProfile reference: [agent], command and placeholdersBox docs
Read moreThe box CLI: box run and its flagsBox docs
What happens when you press Enter on box run
Section titled “What happens when you press Enter on box run”That one command did a lot. In order (from the Box docs, docs/cli/cli.md and docs/cli/how-box-works.md, and the output above):
- Find the profile.
boxlooks forwsin$BOX_HOME/profiles/. (A value with a/or ending in.tomlis read as a path to a profile file instead.) - Resolve it.
boxreadsprofile.tomland each pack it names, merges them (packs left to right, the profile last), fills in placeholders such as${{ home }}, and checks the policy. A mistake stops here withbox: error:and leaves no run folder. This is the same workbox profile showdoes. - Copy files into storage on the profile’s first run, if a pack asks for copies. Our profile asks for none.
- Create the run. A new box ID, a run folder
$BOX_HOME/r/<box ID>/, and in it the generatedbox.toml(Box Core’s configuration) andpolicy.dw(the run’s rules).boxprints the ID and the records path. - Start Box Core. Core creates the box and its trusted process: the policy engine, the egress gateway, and the vault that holds real secrets. It makes a stand-in for each declared secret, builds the operating system sandbox (on macOS, Seatbelt), prints its startup report, and starts the agent’s
commandin the sandbox. - Pass your arguments. Everything after
--is added at theagent-argsslot. Box does not read or change them. - Wait. Core runs until the agent exits, and
box runexits with the agent’s status. The run folder stays until you clean it up.
Read moreHow Box worksBox docs
Read moreArchitecture: the agent’s sandbox and the trusted processBox docs
Run Claude Code for real
Section titled “Run Claude Code for real”--version proved the box can start the program. Now give Claude Code a real task, and fix what it lacks, one setting at a time.
From here on every iteration uses the same free check: a run that sets the model key to an invalid value for that one command. Claude Code starts, reaches its first model call, gets refused by Anthropic, and exits. Nothing is billed.
The run. The free check.
What this doesStarts Claude Code in the box for one headless turn, with an invalid model key so nothing is billed.
ANTHROPIC_API_KEY=sk-ant-preflight-invalid-key box run ws --no-banner -- --bare -p "Say hello." \ --max-turns 1 --model claude-sonnet-5-5 < /dev/nullANTHROPIC_API_KEY=sk-ant-preflight-invalid-keyNAME=value prefix changes the variable for this one command only. The value is not a real key, so the first model call fails and costs nothing. This check has no money cap of its own, so never drop the prefix from it.--bareANTHROPIC_API_KEY. It keeps your own Claude Code set-up out of the box.-p "Say hello."--max-turns 1--model claude-sonnet-5-5< /dev/null\What we see. Claude Code prints, and exits 1:
Can't read the current directory (EPERM). Start Claude Code from a different directory.EPERM is the operating system’s “operation not permitted”. The sandbox let the agent enter the project folder but not read it, which is what Box’s first line warned about.
What we add. Project access, read only.
[project]access = "read"
[agent]command = ["${{ home }}/.local/bin/claude", { slot = "agent-args" }]The project is the folder box run starts in, here ~/leaderboard-ops. [project] access decides how much of it the agent, its tools and its MCP servers reach. Box also writes matching rules for the box’s own shell (project_read). With the line in place, each run prints:
box: the agent can read but not change this project (`[project] access = "read"` in ~/box-ws/profiles/ws/profile.toml)Read moreProfile reference: [project]Box docs
Read moreClaude Code CLI referenceClaude Code docs
The run. The same free check. What we see:
EPERM: operation not permitted, open '/tmp/claude-502'Claude Code wants a temporary folder under /tmp (the number is your user ID). The sandbox grants nothing there.
What we add. A storage folder for temporary files, and a variable that tells Claude Code to use it.
[project]access = "read"
[storage]directories = ["tmp"]
[agent]command = ["${{ home }}/.local/bin/claude", { slot = "agent-args" }]
[agent.env]CLAUDE_CODE_TMPDIR = "${{ storage.tmp }}"[storage] directoriesnames folders the agent keeps between runs."tmp"becomes~/box-ws/storage/ws/default/agent/tmp, which the agent may read and write.${{ storage.tmp }}is the placeholder for that folder’s full path.[agent.env]is the agent’s whole environment. The agent inherits nothing from your shell, except what Box itself sets.CLAUDE_CODE_TMPDIRis Claude Code’s variable for its temporary folder.
Read moreProfile reference: [storage] and [agent.env]Box docs
The run. The same free check. What we see:
These settings did not load, so nothing in them is in effect, including hooks, permission rules and sandbox settings, though environment variables they already set can stay: ~/.claude/settings.json: Settings file could not be read: EPERM: operation not permitted, stat '~/.claude/settings.json'Fix each problem listed, then start Claude Code again. ...Not logged in · Please run /loginThis refusal is good news for both seats. Box set the agent’s HOME to your home folder, but granted nothing in it, so the sandbox refused Claude Code even a look (stat) at your real ~/.claude/settings.json. Your configuration cannot leak in.
Claude Code still needs a configuration folder of its own. Give it one in storage.
What we add. A second storage folder, and the variable that points Claude Code at it.
[project]access = "read"
[storage]directories = ["config", "tmp"]
[agent]command = ["${{ home }}/.local/bin/claude", { slot = "agent-args" }]
[agent.env]CLAUDE_CONFIG_DIR = "${{ storage.config }}"CLAUDE_CODE_TMPDIR = "${{ storage.tmp }}"Line 5 changed: "config" was added. CLAUDE_CONFIG_DIR is Claude Code’s variable for the folder that holds its settings, .claude.json, sessions and transcripts.
What we see after the change. Only:
Not logged in · Please run /loginThe settings error is gone. Storage now holds agent/config/.claude.json, projects/, sessions/ and more: an empty Claude Code configuration that belongs to this profile and survives between runs. “Not logged in” is the next page’s problem: the model key does not reach the agent.
What we add. One pack, as the first line of the file.
packs = ["@box/base"]
[project]access = "read"
[storage]directories = ["config", "tmp"]
[agent]command = ["${{ home }}/.local/bin/claude", { slot = "agent-args" }]
[agent.env]CLAUDE_CONFIG_DIR = "${{ storage.config }}"CLAUDE_CODE_TMPDIR = "${{ storage.tmp }}"packs is a top-level key. Top-level keys (packs, policies and a few others) must come before the first [table]; after a table starts, every key belongs to that table.
@box/base is a small support pack that every shipped agent pack builds on. It sets three variables for the agent: TERM and COLORTERM (taken from your shell, with defaults) and a fixed PATH=/usr/bin:/bin. It grants nothing else.
The run. The same free check. What we see: the same Not logged in, and one changed line at the end of Box Core’s startup report. Before:
strands-box: [agent] HOME=~ PATH=~/box-ws/r/b-.../box/bin:<the whole PATH of your shell>After:
strands-box: [agent] HOME=~ PATH=~/box-ws/r/b-.../box/bin:/usr/bin:/binThe box/bin folder at the front is Box’s own: it holds the aliases Box uses to start MCP servers (Part 5).
Now box profile show ws resolves:
box: Profile ws
✓ Resolves for this directory packs @box/base 1 storage ~/box-ws/storage/ws/default project read only
Options terminal.colorterm "truecolor" (env:COLORTERM) terminal.term "xterm-256color" (env:TERM)
Full configuration: box profile show ws --fullThe 1 after @box/base is the pack’s version. The options are the pack’s inputs and where their values came from (env:TERM means “your shell’s TERM”). Which terminal.colorterm line you see depends on your shell: if it does not set COLORTERM, the line ends in (default) instead of (env:COLORTERM).
Read morePacksBox docs
Read moreThe @box/base pack, the whole fileBox docs
The two seats
Section titled “The two seats”The agent now runs in a sandbox that reaches its own binary, two storage folders and a read-only project, and nothing else of the home folder. File refusals such as the EPERM above come from the operating system sandbox, not from a policy rule, so they leave no row in the run’s decision history; you only see them in the agent’s own error output (a gap, listed in Builds and gaps).
Claude Code starts, but cannot work yet: it has no model key and no network. Each setting cost one short run to find. The profile is 14 lines, and every line is one you can explain.
What to remember
Section titled “What to remember”- A profile is one hand-written
profile.tomlin$BOX_HOME/profiles/<name>/. A pack is a reusable piece of profile; a starter is the question list that writes a profile, and is never read again. [agent] commandis an argument list, and{ slot = "agent-args" }is where your--arguments go.- The agent inherits nothing: no files beyond its grants, no variables beyond
[agent.env]. - Storage keeps the agent’s own folders between runs; each run gets a new box ID and a run folder.
box profile showchecks a profile without starting anything. Run it after every change.
Read moreProfile referenceBox docs
Read moreWhere Box keeps its filesBox docs
Read moreWhat a sandbox containsThis workshop