/claude-code-superpowers:system-boundariesfrom claude-code-superpowers
Defines Claude Code's internal vs. external system boundaries: Claude API, MCP servers, file system, shell, and Git. Use when adding integrations or deciding where a new capability should live.
Ships in claude-code-superpowers. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Claude Code has a clear inside/outside line. Inside: the conversation loop, tool execution, state management, permission checking, and UI rendering. Outside: the Claude API (LLM inference), MCP servers (dynamic tool extension), the local file system, the shell, Git, OAuth providers, and remote CCR infrastructure.
The boundary is managed by: the services/api/ module for the Claude API, the services/mcp/ module for MCP clients, sandboxed path resolution for file system access, and execFile wrappers (never exec with shell interpolation) for shell and Git commands.
Each external system has its own failure modes. The Claude API can return 429 (rate limit), timeout, or return malformed tool call JSON. MCP servers can disconnect or return unexpected schemas. The file system can have permission errors or ENOENT. Shell commands can hang or have non-zero exit codes. Git can be absent or on an unexpected version.
By routing all external access through boundary modules (services/api/, services/mcp/, utils/git.ts), error handling and retry logic lives in one place. Tools don't need to handle rate limits or reconnection — they call the boundary, and the boundary handles the failure modes of that external system.
services/api/. This gives you automatic retry, token budget tracking, and streaming.services/mcp/MCPServerConnection. Register tools via mcpClients in ToolUseContext.options.getResolvedPath() or equivalent — this enforces the sandbox (additional working directories) and prevents path traversal. Use fs.promises (not sync variants).execFileNoThrow() or execFileSafe() from utils/bash/ — these pass arguments as arrays (not strings), preventing shell injection. Never use exec() with string interpolation.getGitStatus(), getBranch(), getDefaultBranch() from utils/git.ts — these wrap git in execFileNoThrow and handle the "not a git repo" case gracefully.services/[name]/ module, implement error handling for that system's failure modes, and expose a clean interface that tools can call without knowing about HTTP status codes or connection state.// Source: src/utils/git.ts (Git as a boundary — never raw shell strings)
import { execFileNoThrow } from './bash/execFile.js'
// git commands are called with argument arrays, NEVER string interpolation
// This prevents injection: gitExe() ['log', '--oneline', userInput] is safe
// exec(`git log ${userInput}`) would be injectable
export const getBranch = async (): Promise<string> => {
const result = await execFileNoThrow(
gitExe(),
['--no-optional-locks', 'rev-parse', '--abbrev-ref', 'HEAD'],
)
return result.trim()
}
// Source: src/context.ts (graceful "not a git repo" handling at boundary)
export const getIsGit = async (): Promise<boolean> => {
const result = await execFileNoThrow(
gitExe(),
['rev-parse', '--is-inside-work-tree'],
)
return result.trim() === 'true'
}
// Source: src/services/mcp/ (MCP as dynamic extension, not hardcoded tools)
// MCP servers register tools at runtime — Claude Code doesn't know their schemas at compile time
// The MCPTool wrapper handles this: it defers tool lookup until ToolSearch is called
// context.options.mcpClients contains live connections to registered MCP servers
// Source: src/tools/BashTool/BashTool.tsx (sandbox enforcement)
async call(args, context, canUseTool) {
// Path access is not checked inside BashTool — the permission system handles it
// But file-access tools check against additionalWorkingDirectories in AppState:
const resolvedPath = getResolvedPath(args.file_path, {
additionalWorkingDirectories: context.getAppState().settings.additionalWorkingDirectories,
cwd: getCwd(),
})
// If outside sandbox: permission system will deny before execution
}
The key security detail: Claude Code uses execFile() (argument arrays) everywhere, never exec() (shell strings). This applies to git, bash helpers, and any other subprocess. A tool input of "$(cat ~/.ssh/id_rsa)" would be a literal string argument to the subprocess, not executed by the shell.
Before — tool calling external system without boundary module:
async call(args, context, canUseTool) {
// Wrong: direct fetch to external API with no retry, no rate limit handling
const response = await fetch(`https://api.github.com/repos/${args.repo}`)
const data = await response.json()
return { type: 'success', data }
}
After — tool using a boundary module:
// src/services/github/index.ts — boundary module owns HTTP concerns
export async function getRepoInfo(repo: string, signal?: AbortSignal): Promise<RepoInfo> {
const response = await fetchWithRetry(`https://api.github.com/repos/${repo}`, {
headers: { Authorization: `Bearer ${await getGithubToken()}` },
signal,
})
if (response.status === 404) throw new GitHubNotFoundError(repo)
if (response.status === 403) throw new GitHubRateLimitError()
if (!response.ok) throw new GitHubAPIError(response.status, response.statusText)
return response.json() as Promise<RepoInfo>
}
// Tool calls boundary, not raw fetch
async call(args, context, canUseTool) {
const permission = await canUseTool(GitHubTool, args, context)
if (!permission.granted) return { type: 'error', error: permission.reason }
try {
const info = await getRepoInfo(args.repo, context.abortController.signal)
return { type: 'success', data: info }
} catch (err) {
if (err instanceof GitHubNotFoundError) {
return { type: 'error', error: `Repository ${args.repo} not found.` }
}
if (err instanceof GitHubRateLimitError) {
return { type: 'error', error: 'GitHub API rate limit exceeded. Try again in a minute.' }
}
return { type: 'error', error: `GitHub API error: ${err instanceof Error ? err.message : String(err)}` }
}
}
fetch(), exec(), or reads from process.env without going through a service module\git ${userInput}``) instead of argument arraysadditionalWorkingDirectories — only checks process.cwd()services/api/ directly for a non-Claude-API purposeutils/ is fineerror-handling — boundary modules define the custom error types that tools catchpermission-system — the permission system gates access at the boundaryasync-concurrency — boundary modules accept and forward AbortController signalsWhat SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
Generated from the plugin's indexed repository (techymt/claude-code-superpowers) — no native marketplace selected
npx claudepluginhub p/techymt-claude-code-superpowers16 skills in this plugin
/async-concurrencyTeaches Claude Code's concurrency model: isConcurrencySafe() for parallel tool execution, AbortController propagation for cancellation, Promise.all() for parallel initialization, and the StreamingToolExecutor for concurrent progress streams. Use this when writing tools that could benefit from parallel execution, need to respect cancellation, or must stream partial results. Read-only tools that don't declare concurrency safety are needlessly serialized.
/build-tool-factoryTeaches how to create a new Claude Code tool using the buildTool() factory from src/Tool.ts.
Use this whenever adding a new capability to Claude Code — buildTool is the only correct entry
point. It fills in safe defaults for isConcurrencySafe, isReadOnly, isDestructive,
checkPermissions, and userFacingName so you only implement what your tool actually needs.
/creating-skillsOther plugins' skills for the same job