/claude-code-superpowers:module-organisationfrom claude-code-superpowers
Documents Claude Code's module organization by responsibility boundary: tools, commands, services, state, hooks, components, and utils. Helps decide where to place new code or trace behavior.
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 organizes code by responsibility, not by feature. Each top-level directory under src/ owns a specific layer of the system. Tools live in tools/, each in its own subdirectory named [Name]Tool/. Commands live in commands/, each in its own subdirectory or file. Business logic lives in services/. AppState lives in state/. React hooks live in hooks/. React components (TUI rendering) live in components/. Pure utility functions live in utils/.
The rule: a tool knows how to execute a capability. A service knows how to coordinate across multiple tools or external systems. A component knows how to render state. A hook knows how to subscribe to state. These never cross — a tool does not render, a component does not call a bash command.
Claude Code is a React application running in a terminal. It has the full complexity of a web app (UI state, async data, event handling) plus the additional complexity of a capability system (tools, permissions, streaming). Without strict layer separation, service logic leaks into components, rendering logic leaks into tools, and state management becomes implicit.
The per-tool subdirectory pattern (tools/BashTool/BashTool.tsx) is intentional: each tool is large enough to warrant its own namespace. BashTool.tsx uses .tsx because bash output can be rendered as JSX in the TUI. FileReadTool.ts uses .ts because its output is plain data. The file extension signals whether the tool has UI concerns.
src/tools/[Name]Tool/[Name]Tool.ts[x]. Export the tool as a named constant. Register it in src/tools.ts./something): create src/commands/something/index.ts or src/commands/something.ts. Register it in src/commands.ts.src/services/[name]/. Keep all HTTP/socket code here.AppStateStore.ts's AppState type. Add it to initialState. Expose a selector in state/selectors.ts.src/hooks/use[Name].ts.src/components/[Name].tsx.src/utils/[name].ts. No side effects, no imports from state/ or tools/.src/
├── tools/ # Capabilities: each is a Tool<Input, Output>
│ ├── BashTool/
│ │ ├── BashTool.tsx # .tsx: renders bash output as JSX
│ │ ├── bashPermissions.ts
│ │ └── bashUtils.ts
│ ├── FileReadTool/
│ │ └── FileReadTool.ts # .ts: plain data, no rendering
│ ├── AgentTool/
│ │ └── AgentTool.tsx # Spawns subagents — has UI progress
│ └── GlobTool/
│ └── GlobTool.ts
│
├── commands/ # User slash commands: /commit, /add-dir, /plan
│ ├── commit.ts # Simple command: single file
│ ├── config/ # Complex command: subdirectory
│ │ ├── index.ts
│ │ └── configHelpers.ts
│ └── add-dir/
│ └── index.ts
│
├── services/ # Cross-cutting business logic
│ ├── api/ # Claude API client
│ ├── mcp/ # Model Context Protocol
│ ├── compact/ # Message compaction algorithm
│ ├── tools/ # Tool orchestration (not tool implementations)
│ │ └── toolOrchestration.ts
│ └── analytics/
│
├── state/ # AppState: single source of truth
│ ├── AppStateStore.ts # Type + initial state (700 lines)
│ ├── AppState.tsx # React provider
│ ├── store.ts # Zustand factory
│ └── selectors.ts
│
├── utils/ # Pure functions, no side effects
│ ├── messages.ts # Message normalization pipeline
│ ├── permissions/ # Permission rule matching
│ ├── bash/ # Bash command parsing
│ └── file.ts # File path helpers, isENOENT()
│
├── hooks/ # React hooks (state subscriptions)
│ ├── useCanUseTool.ts
│ └── useSettingsChange.ts
│
└── components/ # TUI components (Ink/React)
├── REPL.tsx
└── Spinner.tsx
The services/tools/ directory is distinct from tools/ — it contains the orchestration logic (scheduling, concurrency, budgeting) that runs tools, not the tool implementations themselves. This prevents tools from knowing about their own scheduling.
Before — new capability added directly to the query loop:
// src/query.ts — wrong: capability logic polluting the message loop
async function handleToolCall(toolName: string, input: unknown) {
if (toolName === 'search_logs') {
// 50 lines of log-searching logic inline here
const logs = await readLogsFromDisk(input.path)
return { content: formatLogs(logs) }
}
// ...
}
After — capability in the correct location:
// src/tools/SearchLogsTool/SearchLogsTool.ts
export const SearchLogsTool: Tool<typeof inputSchema, string> = {
inputSchema,
isConcurrencySafe: (_input) => true,
isReadOnly: (_input) => true,
async call(args, context, canUseTool) { /* ... */ },
async description(input) { return `Search logs in ${input.path}` },
}
// src/tools.ts — register it
import { SearchLogsTool } from './tools/SearchLogsTool/SearchLogsTool.js'
export const getTools = (): Tools => [
// ...existing tools...
SearchLogsTool,
]
state/AppStateStore.ts directly instead of receiving contextutils/ has side effects or imports from tools/src/ root instead of the correct subdirectoryutils/ is fineutils/.tsx extension — only use it if the tool's output is rendered as JSXdomain-model — explains the six concepts that map to these directoriestool-definition — the Tool interface all tools in tools/ implementnaming-conventions — file and export naming within each moduleWhat SKILL.md sets; muted values are Claude Code's defaults
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-skillsUse when extracting an engineering pattern from a codebase and packaging it as a skill for an AI assistant. Triggered when: converting a recurring code pattern into a SKILL.md, wanting your AI to apply a specific pattern automatically, or validating whether an existing skill is good enough to ship. Covers structure, the real-code requirement, the two-layer generic/specific design, and six quality tests.
/domain-modelTeaches Claude Code's core domain model: Tool, Message, Task, ToolUseContext, AppState, and Command — the six concepts every part of the system is built around. Use this before writing any new tool, command, or feature that touches the conversation loop. Essential for understanding how Claude's capability system is structured and why the abstractions exist.
/error-handlingTeaches Claude Code's error philosophy: tool call() throws typed errors, the framework catches them and formats them for the LLM as structured tool result content, and custom error types carry structured context at system boundaries. Use this whenever writing a tool, utility function, or service that can fail. The distinction between "errors the LLM should see" and "errors that crash the session" is the core insight.
/hot-pathsTeaches Claude Code's startup and runtime performance patterns: lazySchema() for deferred Zod parsing, feature() flags for build-time dead code elimination, memoize() for expensive repeated computations, parallel initialization with Promise.all(), and profileCheckpoint() for tracking load times. Use this whenever writing code that runs at startup, on every turn, or in a hot loop. Startup latency is Claude Code's most user-visible performance metric.
Other plugins' skills for the same job