Claude Code agent teams that share files safely
Fred Chang ·
When Claude Code starts a helper agent, the helper gets every tool and every permission you have. So what could happen is that this agent you asked for could also happen to rewrite it. The better way is to give each agent its own agentleFS identity, limited to one folder, and then any mistake stays inside that folder.
TLDR: connect your main Claude Code session (the lead) to agentleFS. Have it create one limited identity per subagent. Point each subagent at its own connection. Retire them all with one call when the work is done.
What are Claude Code subagents and agent teams?
Both split work across several Claude contexts:¹ ²
| Subagents | Agent swarms | |
|---|---|---|
| What it is | A helper with its own context window, defined in .claude/agents/ | Several full Claude Code sessions: one lead, the rest teammates |
| How they talk | Return a result to the caller | Message each other and share a task list |
| Status | Built in | Experimental, off until you set CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1 |
| Nesting | Up to three layers below the main conversation | Teammates cannot spawn teammates |
Use subagents when only the answer matters, and a swarm when the agents need to debate.
What does a Claude Code subagent inherit?
- MCP tools. These are the outside services your session connects to, such as agentleFS. "Subagents inherit the built-in tools and MCP tools available in the main conversation."¹ So every subagent can write wherever your session can, unless
disallowedToolsremoves the tool. - Permission mode. This decides whether Claude Code asks before it acts. If the main conversation runs in
bypassPermissions,acceptEditsor auto mode, "the subagent runs in that same mode". Its ownpermissionModeis ignored.¹ - Teammates too. "If the lead runs with
--dangerously-skip-permissions, all teammates do too."²
How agentleFS scopes each agent
In agentleFS an agent is an identity under whoever started it. It can reach only what its person can reach.
- A scope, not a copy. Each agent you spawn gets a role (Viewer, Editor or Manager) at one location, such as
viewer@projects/launch. It can never exceed its parent. If your access shrinks, so does the agent's. - Ending a link cuts everything below. Retire an agent and everything it spawned ends too. A child never outlives its parent's expiry.
- A record. agentleFS keeps every version. It logs every read, write and refusal with the chain: subagent, lead, person.
The caveat: a client that signs in through the browser, Claude Code included, acts as you, with your full access. Only the identities it spawns are narrowed.
A worked example: a lead and two scoped subagents
projects/launch holds research notes and a drafts folder. I want one subagent that only reads, and one that writes only drafts.
1. Spawn two identities. In a Claude Code session connected to agentleFS:
In afs, spawn two agents in projects/launch, expiring Friday: "researcher" with scope viewer@projects/launch, and "drafter" with scope editor@projects/launch/drafts.
The answer names each agent and how to start it. It never carries a key: agentleFS hands no credential to an AI session, and has no long-lived keys at all. Whatever Claude prints lands in the chat transcript, and the transcript is saved, so a key there would sit there for good.
Instead, sign the machine in once, in your own terminal:
afs-run login --folder projects/launch
It prints an address and a code; you approve it in your browser, and the machine keeps its own credential in a file only you can read. Nothing secret is typed, pasted or exported. afs-run is in the agentlefs-workflows plugin, or at https://mcp.agentlefs.com/install/afs-run.
If that credential leaks anyway, it can't do much. It reaches one folder, it ends if unused for 30 days, and revoking the machine in the console stops every agent it started.
2. Give each subagent its own connection. A subagent file can define its own MCP server, with the same schema as .mcp.json.¹ ⁴ .claude/agents/researcher.md runs the launcher's stdio bridge as that agent, which sends the agent's current fifteen-minute token on every call:
---
name: researcher
description: Reads the launch notes and comments on gaps. Never edits.
disallowedTools: mcp__plugin_agentlefs_agentlefs
mcpServers:
- afs-researcher:
type: stdio
command: afs-run
args: ["mcp", "--agent", "@researcher"]
---
Read projects/launch in afs. Where a claim has no source,
leave a comment on that sentence. Do not edit files.drafter.md is the same, with @drafter and a prompt to write in projects/launch/drafts.
disallowedTools removes the lead's own agentleFS tools, which carry my full access. Their name depends on how you installed agentleFS. It is mcp__plugin_agentlefs_agentlefs from the plugin, which the connect prompt installs, or mcp__agentlefs if you ran claude mcp add agentlefs. /mcp shows which.
3. Run it. "Use the researcher to check the launch notes, then the drafter to write the announcement." If the drafter writes outside drafts, or the researcher tries to edit, the server refuses. The prompt said "never edits". The scope makes it true.
4. End it. "In afs, retire researcher and drafter." By default each gets an hour to publish anything worth keeping. Ask for a zero window to end them now. Then its sessions stop working, and anything it spawned ends too. If I forget, Friday's expiry does it.
With an agent team, use split panes. Teammates in split panes apply a subagent definition's mcpServers. In-process teammates load your project's servers instead,² and with them the lead's full access.
Can a subagent spawn its own subagents?
In Claude Code, up to three layers deep.¹ In agentleFS a child gets only part of its parent's scope. The drafter could give a helper editor@projects/launch/drafts/intro.md, but never projects. Retiring the drafter ends the helper.
Try it: sign up free at agentlefs.com, then paste into Claude Code: Set up agentleFS for me by following https://agentlefs.com/connect.md
Related

