Fix superpowers bootstrap injection via `experimental.chat.system.transform` (top-level hook)
Fixes #226
Summary
This PR refactors bootstrap injection to use the experimental.chat.system.transform hook instead of client.session.prompt.
The previous method of injecting a synthetic message caused OpenCode to reset the agent to build on the first prompt (see #226). Using the system transform hook avoids this side effect by modifying the system prompt directly before it is sent to the model.
Implementation
- Removes
injectBootstrapand thesession.created/session.compactedevent handlers. - Exports
experimental.chat.system.transformat the top level of the plugin object. - Appends the bootstrap content to
output.system.
Known Limitations
- The hook currently always injects the full (non-compact) bootstrap because the hook input does not provide the
sessionIDneeded to track compaction state.
📝 Walkthrough
Walkthrough
The superpowers plugin refactors how bootstrap content is injected. The local injectBootstrap helper and its usage in event handlers were removed and replaced with a new public experimental hook experimental.chat.system.transform that computes and appends bootstrap content to the output system messages on demand.
Changes
| Cohort / File(s) | Summary |
|---|---|
Bootstrap Injection Refactoring \.opencode/plugin/superpowers.js |
Removed injectBootstrap helper function and bootstrap injection from session.created and session.compacted event handlers. Added new public experimental hook experimental.chat.system.transform that computes bootstrap content and appends it to output.system when invoked. Tool and find_skills functionality unchanged. |
Estimated code review effort
🎯 3 (Moderate) | ⏱️ ~20 minutes
Possibly related PRs
- obra/superpowers#122: Modifies bootstrap/skill content injection in the same file by marking injected text parts as synthetic, directly related to this refactoring of the injection mechanism.
Poem
🐰 Hops with glee at this refactor so neat,
Bootstrap hooks now march to their own beat,
No more event-bound chains holding sway,
Experimental transforms light the way!
Cleaner, simpler, the code takes its flight ✨
Pre-merge checks and finishing touches
✅ Passed checks (3 passed)
| Check name | Status | Explanation |
|---|---|---|
| Title check | ✅ Passed | The title directly and specifically describes the main change: implementing the experimental.chat.system.transform hook to fix bootstrap injection in the superpowers plugin. |
| Docstring Coverage | ✅ Passed | No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. |
| Description Check | ✅ Passed | Check skipped - CodeRabbit’s high-level summary is enabled. |
✨ Finishing touches
- [ ] 📝 Generate docstrings
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands and usage tips.
my test procedure:
Analyzing system prompt superpowers
Session ID: ses_47aa089a3ffei3XJ1eYhuG297l Created: 1/3/2026, 8:39:44 PM Updated: 1/3/2026, 8:40:40 PM
User
is there something about superpowers in your system prompt
Assistant
Thinking:
Investigating Prompt Content
I'm currently focused on the prompt's content, specifically the potential mention of "superpowers." I'm reviewing the system prompt to determine if it's there. My current perspective is that my adherence to the system prompt is a primary aspect of my behavior. I'm focusing on the <EXTREMELY_IMPORTANT> section and beyond to make my conclusions.
Reviewing Skill Application
I've determined that the "using-superpowers" skill is active and directly relevant, as the request pertains to my inherent capabilities. Though the question is informational, the prompt directly states "You have superpowers." Therefore, I'm confirming this detail, which is outlined in the "Using Skills" section of my operational framework. I will provide a straightforward answer based on this skill's definition.
Confirming Response Details
I have a concrete answer now, though I am balancing it with the concern for the system prompt's potential sensitivity. The system prompt contains the specifics the user is interested in: "You have superpowers," and this is mentioned in the "superpowers skill library" as well. I'm choosing a concise "Yes" as the appropriate reply.
Yes. My instructions state "You have superpowers" and detail how to use a "superpowers skill library" to follow specific workflows for tasks like debugging, testing, and planning.
User
list all superpowers
Assistant
Thinking:
Checking Skill Inventory
I'm currently focused on identifying all the available "superpowers." I'm using the find_skills tool to thoroughly search the skill library, including personal and project skills. This should give me a comprehensive list to work with.
Compiling Skill Lists
I'm now incorporating my library skills. The goal is to create a complete and organized skill inventory. By using the tool, I believe I can get a precise view of all my skills.
Tool: find_skills
**Input:**
```json
{}
Output:
Available skills:
superpowers:systematic-debugging
Use when encountering any bug, test failure, or unexpected behavior, before proposing fixes
Directory: /home/philipp/github/superpowers/skills/systematic-debugging
superpowers:requesting-code-review
Use when completing tasks, implementing major features, or before merging to verify work meets requirements
Directory: /home/philipp/github/superpowers/skills/requesting-code-review
superpowers:using-superpowers
Use when starting any conversation - establishes how to find and use skills, requiring Skill tool invocation before ANY response including clarifying questions
Directory: /home/philipp/github/superpowers/skills/using-superpowers
superpowers:brainstorming
"You MUST use this before any creative work - creating features, building components, adding functionality, or modifying behavior. Explores user intent, requirements and design before implementation."
Directory: /home/philipp/github/superpowers/skills/brainstorming
superpowers:receiving-code-review
Use when receiving code review feedback, before implementing suggestions, especially if feedback seems unclear or technically questionable - requires technical rigor and verification, not performative agreement or blind implementation
Directory: /home/philipp/github/superpowers/skills/receiving-code-review
superpowers:test-driven-development
Use when implementing any feature or bugfix, before writing implementation code
Directory: /home/philipp/github/superpowers/skills/test-driven-development
superpowers:dispatching-parallel-agents
Use when facing 2+ independent tasks that can be worked on without shared state or sequential dependencies
Directory: /home/philipp/github/superpowers/skills/dispatching-parallel-agents
superpowers:executing-plans
Use when you have a written implementation plan to execute in a separate session with review checkpoints
Directory: /home/philipp/github/superpowers/skills/executing-plans
superpowers:finishing-a-development-branch
Use when implementation is complete, all tests pass, and you need to decide how to integrate the work - guides completion of development work by presenting structured options for merge, PR, or cleanup
Directory: /home/philipp/github/superpowers/skills/finishing-a-development-branch
superpowers:writing-plans
Use when you have a spec or requirements for a multi-step task, before touching code
Directory: /home/philipp/github/superpowers/skills/writing-plans
superpowers:writing-skills
Use when creating new skills, editing existing skills, or verifying skills work before deployment
Directory: /home/philipp/github/superpowers/skills/writing-skills
superpowers:using-git-worktrees
Use when starting feature work that needs isolation from current workspace or before executing implementation plans - creates isolated git worktrees with smart directory selection and safety verification
Directory: /home/philipp/github/superpowers/skills/using-git-worktrees
superpowers:subagent-driven-development
Use when executing implementation plans with independent tasks in the current session
Directory: /home/philipp/github/superpowers/skills/subagent-driven-development
superpowers:verification-before-completion
Use when about to claim work is complete, fixed, or passing, before committing or creating PRs - requires running verification commands and confirming output before making any success claims; evidence before assertions always
Directory: /home/philipp/github/superpowers/skills/verification-before-completion
---
## Assistant
_Thinking:_
**Identifying Superpowers!**
I've just received a list of skills, interestingly labeled as "superpowers". My next step is to present them directly. This seems straightforward, but I want to ensure the presentation is clear and impactful.
Here are the "superpowers" (skills) available in my system:
- **systematic-debugging**: Use for bug fixing and troubleshooting.
- **requesting-code-review**: Use to verify work meets requirements before merging.
- **using-superpowers**: Establishes how to find and use these skills.
- **brainstorming**: Use before creative work to explore intent and requirements.
- **receiving-code-review**: Use when processing feedback on your code.
- **test-driven-development**: Use when implementing features or bugfixes.
- **dispatching-parallel-agents**: Use for managing multiple independent tasks.
- **executing-plans**: Use when executing a written implementation plan.
- **finishing-a-development-branch**: Use to guide the completion and integration of work.
- **writing-plans**: Use for multi-step tasks before modifying code.
- **writing-skills**: Use when creating or editing these superpower skills.
- **using-git-worktrees**: Use for isolating feature work from the current workspace.
- **subagent-driven-development**: Use for executing implementation plans with subagents.
- **verification-before-completion**: Use to verify work with evidence before claiming it is done.
---
## User
---
## Assistant
_Thinking:_
**Summarizing the Current State**
I've been gathering details about the recent interactions to create a comprehensive overview. Currently, I'm focused on extracting key actions, active files, ongoing tasks, and future steps. User preferences and technical choices are also being carefully logged for inclusion in the summary.
**Reflecting on Recent Interactions**
I've just reviewed the conversation and outlined the main points. My focus is now on crafting a prompt for a new session based on our discussion about the "superpowers." I'll extract key actions, active files, ongoing tasks, and future steps. User preferences and technical choices are also being carefully logged for inclusion in the summary.
**Revisiting Summarization Strategy**
Okay, so I've been assessing how to best address the user's request for a summary. I realized I don't need a specific "summarizing" skill, because the base instructions already cover this. I'm focusing on the user's query and the actions taken so far: explaining the "superpowers" and listing them after using the `find_skills` skill. There was no code modification.
**Preparing for the Next Step**
I'm now concentrating on developing the prompt for the subsequent session, following our discussion and actions taken. I'm taking the prior conversation, extracted key actions, active files, ongoing tasks, and future steps. User preferences and technical choices are also being carefully logged for inclusion in the summary.
In our conversation so far, we explored the "superpowers" (skills) mentioned in my system prompt.
**Summary of activities:**
- **Identified "Superpowers":** Clarified that "superpowers" refer to a structured skill library that guides my workflows for tasks like debugging, planning, and development.
- **Listed Available Skills:** Used the `find_skills` tool to retrieve a comprehensive list of all available superpower skills, including `systematic-debugging`, `test-driven-development`, `brainstorming`, and `writing-plans`.
- **Status:** We have established the capabilities and protocols of the assistant but have not yet initiated a specific development task or modified any files.
**Prompt for the next session:**
> "I am continuing a conversation where we just reviewed your available 'superpowers' (skills). You have already listed the skills available in the system (such as `systematic-debugging`, `TDD`, `brainstorming`, etc.).
>
> We are ready to start a task. Please remember to use the `using-superpowers` protocol: identify and invoke the relevant skill (like `brainstorming` for new features or `writing-plans` for multi-step tasks) before taking action or writing code."
**Next Steps:**
- Decide on a specific project or task to work on.
- Select the appropriate superpower skill to initiate the workflow (e.g., `brainstorming` for a new feature).
---
## User
are the superpowers still here?
---
## Assistant
_Thinking:_
**Assessing Superpower Availability**
I'm now checking the current list of available skills to confirm the continued presence of these "superpowers." I'll use the `find_skills` tool to get a definitive answer. It seems the system prompt implies the `using-superpowers` skill is loaded, so this check will verify that, as well as ensure any other requested skills are ready.
**Verifying Superpower Presence**
I've determined that the user's focus on superpowers mandates a thorough verification. Given even a slight possibility of a relevant skill, I'll initiate a comprehensive listing. The `list_skills` tool is perfect for this, as it allows me to showcase the continued presence of the superpowers. This proactive approach ensures immediate responsiveness and accuracy in my response to the user's prompt.
Tool: find_skills
Input:
{}
Output:
Available skills:
superpowers:systematic-debugging
Use when encountering any bug, test failure, or unexpected behavior, before proposing fixes
Directory: /home/philipp/github/superpowers/skills/systematic-debugging
superpowers:requesting-code-review
Use when completing tasks, implementing major features, or before merging to verify work meets requirements
Directory: /home/philipp/github/superpowers/skills/requesting-code-review
superpowers:using-superpowers
Use when starting any conversation - establishes how to find and use skills, requiring Skill tool invocation before ANY response including clarifying questions
Directory: /home/philipp/github/superpowers/skills/using-superpowers
superpowers:brainstorming
"You MUST use this before any creative work - creating features, building components, adding functionality, or modifying behavior. Explores user intent, requirements and design before implementation."
Directory: /home/philipp/github/superpowers/skills/brainstorming
superpowers:receiving-code-review
Use when receiving code review feedback, before implementing suggestions, especially if feedback seems unclear or technically questionable - requires technical rigor and verification, not performative agreement or blind implementation
Directory: /home/philipp/github/superpowers/skills/receiving-code-review
superpowers:test-driven-development
Use when implementing any feature or bugfix, before writing implementation code
Directory: /home/philipp/github/superpowers/skills/test-driven-development
superpowers:dispatching-parallel-agents
Use when facing 2+ independent tasks that can be worked on without shared state or sequential dependencies
Directory: /home/philipp/github/superpowers/skills/dispatching-parallel-agents
superpowers:executing-plans
Use when you have a written implementation plan to execute in a separate session with review checkpoints
Directory: /home/philipp/github/superpowers/skills/executing-plans
superpowers:finishing-a-development-branch
Use when implementation is complete, all tests pass, and you need to decide how to integrate the work - guides completion of development work by presenting structured options for merge, PR, or cleanup
Directory: /home/philipp/github/superpowers/skills/finishing-a-development-branch
superpowers:writing-plans
Use when you have a spec or requirements for a multi-step task, before touching code
Directory: /home/philipp/github/superpowers/skills/writing-plans
superpowers:writing-skills
Use when creating new skills, editing existing skills, or verifying skills work before deployment
Directory: /home/philipp/github/superpowers/skills/writing-skills
superpowers:using-git-worktrees
Use when starting feature work that needs isolation from current workspace or before executing implementation plans - creates isolated git worktrees with smart directory selection and safety verification
Directory: /home/philipp/github/superpowers/skills/using-git-worktrees
superpowers:subagent-driven-development
Use when executing implementation plans with independent tasks in the current session
Directory: /home/philipp/github/superpowers/skills/subagent-driven-development
superpowers:verification-before-completion
Use when about to claim work is complete, fixed, or passing, before committing or creating PRs - requires running verification commands and confirming output before making any success claims; evidence before assertions always
Directory: /home/philipp/github/superpowers/skills/verification-before-completion
---
## Assistant
_Thinking:_
**Confirming Superpowers Persist**
I'm confirming that the skills remain active, as detailed previously. I'll stick with the `using-superpowers` protocol for all upcoming tasks, per the user's implicit instructions.
**Invoking Relevant Skills**
I'm now focusing on a new step: ensuring I'm using the `using-superpowers` protocol correctly by checking if any *other* skills are relevant. Since the user is asking about the superpowers, I've already invoked `find_skills` and can tell them I'm on it.
Yes, all the superpowers are still here and ready to use. I've just verified the library, which includes specialized workflows for:
- **Brainstorming** (Creative work and requirement gathering)
- **Writing Plans** (Multi-step task organization)
- **Test-Driven Development** (Feature implementation)
- **Systematic Debugging** (Root-cause analysis and fixing)
- **Subagent-Driven Development** (Parallel execution)
- **Verification Before Completion** (Ensuring everything is actually done)
Whenever we start a new task, I will automatically invoke the most relevant skill to guide our process. What should we tackle first?
---
## User
is it still in your system prompt
---
## Assistant
Yes, the `using-superpowers` protocol and the instructions on how to find and use skills are permanently part of my system prompt.
This ensures that:
1. **Skills are Always Accessible:** I always have the `find_skills` and `use_skill` tools.
2. **Mandatory Invocation:** I am instructed to invoke a skill (even if there's only a 1% chance it applies) before taking action or writing code.
3. **Consistency:** My core workflows (like TDD, debugging, and planning) remain disciplined and consistent across sessions.
I am ready to follow these protocols whenever you give me a task.
---
Can you please elaborate on the limitation? Do you mean that with this PR, a slightly larger prompt would be injected after session compaction? Or is there something more to it?
Since we cannot know if the session is compacted i can not use the compact = true when generating the injection. https://github.com/obra/superpowers/pull/228/files#diff-68edc2bc85cf5cef0e6bf92ceb6e0ae93da7305685274a7a8cb741345b11311cL25-L57 I do not think this is a big drawback, and the remaining logic would be much simpler now.
I agree, having a bit larger post-compaction prompt (by hundreds of tokens?) is a walk in the park compared to needing to manually undo, switch agents and resend the initial prompt in every single new conversation.
Superseded by PR #330, which incorporates this fix along with additional changes (native skills support, Windows docs).
Thank you for identifying the solution!