Superpowers

repository·main·Indexed 13 days ago

https://github.com/obra/superpowers

A software development methodology and skill set for AI coding agents (version 6.2.0). It provides a structured, TDD-driven workflow including brainstorming, implementation planning, and subagent-driven execution. Superpowers is compatible with various platforms including Claude Code, Antigravity, Codex, Cursor, Factory Droid, Gemini CLI, GitHub Copilot CLI, OpenCode, and Pi.

Tokens
121.2K
Snippets
233
Records
440
Agent score
92%

What's inside Superpowers

  1. What is Subagent-Driven Development (SDD)?

    main

    Subagent-Driven Development (SDD) is a methodology for executing implementation plans by dispatching a fresh, specialized subagent for every individual task. This approach ensures high quality and fast iteration by isolating context and preventing context pollution.

    Core Principles:

    • Fresh subagent per task: Each task gets a new agent with precisely crafted instructions and context, rather than inheriting the entire session history.
    • Task Review: Every task is followed by a review of spec compliance and code quality.
    • Broad Final Review: A comprehensive review of the entire branch is performed at the end of the plan.
    • Continuous Execution: Do not pause to check in with a human between tasks. Execute the entire plan unless you are BLOCKED, encounter genuine ambiguity, or all tasks are complete.
    • Minimal Narration: Between tool calls, narrate at most one short line; the ledger and tool results serve as the primary record.
  2. What is a Skill and how to create one using TDD

    main

    A skill is a reusable reference guide for proven techniques, patterns, or tools designed to help agents find and apply effective approaches.

    Writing skills follows a Test-Driven Development (TDD) methodology applied to process documentation. Instead of just writing documentation, you follow a RED-GREEN-REFACTOR cycle:

    1. RED (Test Fails): Create a 'pressure scenario' with a subagent. Observe the agent violating the rule or failing the task without the skill present. Document the exact rationalizations the agent uses.
    2. GREEN (Test Passes): Write the SKILL.md document addressing those specific violations. Verify that the agent now complies with the skill.
    3. REFACTOR: Identify new loopholes or rationalizations the agent uses to bypass the skill, plug them, and re-verify.

    When to create a skill:

    • The technique isn't intuitively obvious.
    • You would reference it across multiple projects.
    • The pattern applies broadly.
    • Others would benefit.

    When NOT to create a skill:

    • For one-off solutions or project-specific conventions (use instructions files instead).
    • For standard practices documented elsewhere.
    • For mechanical constraints that can be automated with regex or validation.
    |
    |-------------|
    | **Test case** | Pressure scenario with subagent |
    | **Production code** | Skill document (SKILL.md) |
    | **Test fails (RED)** | Agent violates rule without skill (baseline) |
    | **Test passes (GREEN)** | Agent complies with skill present |
    | **Refactor** | Close loopholes while maintaining compliance |
    |
  3. How Superpowers maps skills to OpenCode tools

    main

    Superpowers skills use action-oriented language which the plugin maps to specific OpenCode tools. This abstraction allows skills to remain portable across different runtimes.

    Skill ActionOpenCode Tool / Parameter
    "Create a todo" / "mark complete in todo list"todowrite
    Subagent (general-purpose): templatetask tool with subagent_type: "general" (or "explore" for codebase exploration)
    "Invoke a skill"OpenCode's native skill tool
    "Read a file"read
    "Create a file" / "edit a file" / "delete a file"apply_patch
    "Run a shell command"bash
    "Search file contents" / "find files by name"grep, glob
    "Fetch a URL"webfetch
  4. Avoid common plan failures and placeholders

    main

    A plan is considered a failure if it contains placeholders or vague instructions. Every step must contain the actual content an engineer needs to perform the action.

    Do NOT use the following:

    • "TBD", "TODO", "implement later", or "fill in details"
    • Vague instructions like "Add appropriate error handling", "add validation", or "handle edge cases"
    • "Write tests for the above" without providing the actual test code.
    • "Similar to Task N" (always repeat the necessary code blocks; engineers may read tasks out of order).
    • Steps that describe an action without showing how (e.g., missing code blocks for implementation steps).
    • References to types, functions, or methods that are not explicitly defined in any task.
  5. Determine Skill Priority and Sequencing

    main

    When multiple skills apply to a task, follow a hierarchy where process skills are executed before implementation skills. Process skills set the approach, while implementation skills carry out the work.

    Common Patterns:

    • Building new features: Use superpowers:brainstorming first to establish the approach, then use implementation skills (e.g., frontend-design).
    • Fixing bugs: Use superpowers:systematic-debugging first, then use domain-specific skills to execute the fix.

    Always prioritize process skills like brainstorming and systematic-debugging to ensure a disciplined approach.

  6. Principle 1: Name the Break

    main

    A high-quality test must catch a specific, meaningful production change (a bug or a broken contract) rather than just detecting an intentional design decision.

    Key Guidelines:

    • Derive expectations independently: Avoid 'mirror assertions' where the code under test is used to compute the expected value. Use hand-checked literals or fixtures.
    • Avoid change detectors: Do not test things like constant values or exact wording if they don't impact behavior. Instead, test the behavior that depends on that decision (e.g., instead of testing MAX_RETRIES === 5, test that a failing call is retried exactly 5 times).
    • Test behavior, not text: For scripts or documents, do not use grep or string matching on the source. Instead, run the artifact and assert its outputs, side effects, or exit codes.
    • Test your boundaries: Focus on the contract your code makes (routes, queries, payloads) rather than the internal mechanics of upstream frameworks.
    // ❌ Mirror assertion: the same builder computes both sides — always true
    const expected = buildSearchQuery({ tag: 'urgent' });
    expect(buildSearchQuery({ tag: 'urgent' })).toBe(expected);
    
    // ✅ Hand-derived literal
    expect(buildSearchQuery({ tag: 'urgent' })).toBe('tag:"urgent"');
  7. OpenCode Tool Mapping Instructions

    main

    When skills reference tools that are native to other platforms (like Claude Code), OpenCode agents should use the following mappings:

    Original ToolOpenCode Equivalent
    TodoWriteupdate_plan
    Task (with subagents)Use OpenCode subagent system via @mention
    Skill tooluse_skill custom tool
    Read, Write, Edit, BashUse native OpenCode equivalents

    Note on Skill Directories: Skill directories may contain supporting scripts (run via bash), additional documentation (read via read tool), and skill-specific utilities.

  8. Harness-specific worktree models and skill mechanisms

    main

    Superpowers uses a 'detect-and-defer' strategy to handle worktrees across different AI harnesses. The mechanism used depends on whether the harness provides a native, agent-callable tool or requires a manual git fallback.

    HarnessCurrent worktree modelSkill mechanism
    Claude CodeAgent-callable EnterWorktreeStep 1a (Native tool preference)
    Codex CLINo native tool (shell only)Step 1b (git fallback)
    Gemini CLILaunch-time --worktree flag, no agent toolStep 0 (if launched with flag) or Step 1b
    Cursor AgentUser-facing /worktree, no agent toolStep 0 (if user activated) or Step 1b
    Codex AppPlatform-managed, detached HEAD, no agent toolStep 0 (detects existing)
    OpenCodeDetection only (ctx.worktree), no agent toolStep 1b (git fallback)
  9. Understand the Hierarchy of Instructions

    main

    Instructions follow a specific precedence order. When resolving conflicts between different instruction sources, follow this hierarchy:

    1. User Instructions (Highest Priority): Direct requests from the user or configuration files like CLAUDE.md, AGENTS.md, or GEMINI.md.
    2. Superpowers Skills: The workflows defined within the superpowers repository.
    3. Default Behavior (Lowest Priority): The standard operating procedure of the agent/platform.

    Only skip a skill workflow if the human partner has explicitly instructed you to do so.

  10. How the Brainstorm Server handles WebSocket connections

    main

    The server implements a zero-dependency WebSocket protocol layer to facilitate real-time communication between the server and clients (like browsers).

    • Upgrades: The server handles the upgrade event to switch from HTTP to the WebSocket protocol.
    • Message Handling:
      • TEXT: JSON-encoded messages are parsed. If a message contains a choice key, the event is appended to a .events file in the BRAINSTORM_DIR.
      • PING/PONG: The server responds to PING frames with PONG to maintain the connection.
      • CLOSE: Gracefully handles connection termination.
    • Broadcasting: The server can broadcast messages (e.g., { "type": "reload" }) to all connected clients, triggering UI updates when files change.
  11. The Rule for using Superpowers

    main

    When using the superpowers system, you must invoke relevant or requested skills BEFORE any response or action. This includes before asking clarifying questions, exploring the codebase, or checking files.

    Workflow:

    1. Identify if a skill applies (if there is even a 1% chance, you must invoke it).
    2. Announce your intent using the format: Using [skill] to [purpose].
    3. Follow the skill's specific instructions exactly. If the skill contains a checklist, create a todo item for each requirement.

    Note on Brainstorming: Before entering 'plan mode', if you have not yet brainstormed, you must invoke the superpowers:brainstorming skill first.

  12. Enforce WebSocket Origin Validation

    main

    To prevent cross-origin WebSocket attacks, the server enforces origin matching. When a WebSocket upgrade request is received, the server validates that the Origin header matches the Host header.

    • Browser Clients: Must provide an Origin header that matches http://<host>. If the origin is cross-site, the connection is destroyed.
    • Non-Browser Clients: If no Origin header is present, the server allows the connection, provided the client uses a valid session key in the query string.

    Implementation logic for the check:

    function isAllowedWebSocketOrigin(req) {
      const origin = req.headers.origin;
      if (!origin) return true; // non-browser clients still need the session key
      const host = req.headers.host;
      if (!host) return false;
      return origin === 'http://' + host;
    }