Claude Code
Claude Code adapter contract
Overview
@stax/claude-code is the canonical stax adapter for Claude Code.
Its job is to materialize a canonical stax agent into the exact project-scoped or user-scoped files Claude Code expects, while making lossy transformations explicit.
This adapter targets the documented Claude Code file contract described in 17 — Runtime File Contracts.
Scope model
Claude Code supports multiple scopes.
| Scope | Typical files |
|---|---|
| User | ~/.claude/CLAUDE.md, ~/.claude/skills/**, ~/.claude/settings.json, ~/.claude/agents/*.md, ~/.claude.json |
| Project | CLAUDE.md or .claude/CLAUDE.md, .claude/skills/**, .claude/settings.json, .mcp.json, .claude/agents/*.md |
| Local override | .claude/settings.local.json |
In stax 1.0.0, @stax/claude-code SHOULD default to project scope unless the user explicitly requests user scope.
The adapter MUST NOT generate .claude/settings.local.json unless explicitly asked, because it is local-only and should not be shared by default.
Adapter interface
interface ClaudeCodeAdapterOptions {
model?: string;
modelParams?: Record<string, unknown>;
scope?: "project" | "user";
exact?: boolean;
instructionsFile?: "CLAUDE.md" | ".claude/CLAUDE.md";
writeSkills?: boolean; // default: true
writeMcp?: boolean; // default: true
writeSettings?: boolean; // default: true
permissions?: {
allowedTools?: string[];
denyRules?: string[];
};
settings?: Record<string, unknown>; // Claude-specific settings payload
}The compiled adapter config SHOULD use:
{
"type": "claude-code",
"runtime": "claude-code",
"adapterVersion": "1.0.0"
}type: "claude" MAY be accepted as a compatibility alias, but claude-code is preferred for new artifacts.
Target mapping
Project scope
| stax source | Target |
|---|---|
surfaces/instructions.md or composed prompt | CLAUDE.md or .claude/CLAUDE.md |
skills/ | .claude/skills/ |
subagents | .claude/agents/*.md |
| MCP layer | .mcp.json |
| adapter settings/config | .claude/settings.json |
User scope
| stax source | Target |
|---|---|
surfaces/instructions.md or composed prompt | ~/.claude/CLAUDE.md |
skills/ | ~/.claude/skills/ |
subagents | ~/.claude/agents/*.md |
| adapter settings/config | ~/.claude/settings.json |
| MCP layer | ~/.claude.json |
CLAUDE.md generation
Claude Code has one main instruction document at a given scope.
If a consumer has an exact source document for that target, it SHOULD preserve bytes exactly.
Exact source preference
The adapter SHOULD choose the first available source in this order:
surfaces/instructions.mdprompt- synthesized composition
Composed CLAUDE.md order
If composition is required, the adapter SHOULD render sections in this order:
surfaces/instructions.mdpromptsurfaces/persona.mdor a rendered persona summary- translated rules
surfaces/tools.mdsurfaces/identity.mdsurfaces/user.mdsurfaces/heartbeat.md
In exact mode, if composition is required because no exact source document exists, the consumer MUST warn or fail according to policy.
MCP mapping
Claude Code uses .mcp.json for project scope and ~/.claude.json for user scope.
Project output example
{
"mcpServers": {
"github": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-github"]
},
"analytics": {
"transport": "http",
"url": "https://mcp.example.com/analytics"
}
}
}Mapping rules
- stdio servers map to
command,args, and optionalenv - remote servers map to
urland transport-specific fields - secret values MUST NOT be written directly; environment-variable references MAY be used where the runtime supports them
- unsupported canonical MCP fields MUST trigger warnings
Settings mapping
The adapter SHOULD write Claude-specific configuration into .claude/settings.json or ~/.claude/settings.json.
Example:
{
"model": "claude-opus-4-1",
"permissions": {
"allowedTools": ["Read", "Edit", "Bash", "Grep", "Write"],
"denyRules": ["Bash(rm -rf *)"]
}
}The adapter MUST NOT write secret values into the settings file.
Skills mapping
stax skills map directly to Claude Code skills:
- target directory:
.claude/skills/or~/.claude/skills/ - each top-level skill directory MUST be preserved
SKILL.mdcontent SHOULD be preserved byte-for-byte
Subagents mapping
When a subagents layer is present, the adapter SHOULD materialize each named subagent to:
.claude/agents/<name>.mdin project scope~/.claude/agents/<name>.mdin user scope
Consumers SHOULD preserve the compiled instruction bytes and warn when Claude-specific metadata cannot represent a canonical subagent field exactly.
Exactness requirements
An implementation claiming exact Claude Code support SHOULD:
- support project and user scopes
- write
.mcp.jsonfor project MCP config - write
.claude/settings.jsonfor settings - preserve skill directory structure exactly
- materialize subagents to
.claude/agents/*.mdwhen present - avoid generating local-only files by default
- warn or fail when synthesizing
CLAUDE.md
Files the adapter MUST NOT own by default
.claude/settings.local.json- auth tokens or credential files
- caches, logs, session state
- undocumented internal files