[Feature] Inject the repowise steer into subagents via a SubagentStart hook

Open
#6,286 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@Papito084 is already working on this.

Since Nov 26, 2026.

  • #6392 by @Papito084 — open

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
42/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
python
Domain
devtools

Research direction

Start with the SubagentStart route in augment_cmd/command.py and the existing SessionStart handler in augment_cmd/session_start.py, which also holds the _find_repo_root and state.json check to reuse. Add the hook entry to plugins/claude-code/hooks/hooks.json and the backfill in editor_integrations/claude_config.py. Done when a SubagentStart payload in an indexed repo emits the AGENT_STEER_DEFERRED line and nothing is emitted outside one; the open question on matcher scope needs a maintainer decision first.

Written by the indexing model from the issue text.

Description

Problem

Subagents (Explore, Plan, general-purpose, custom agents) never see repowise's "call a Repowise MCP tool first" rule. They open with Grep and Read, even in indexed repos.

The rule (AGENT_STEER_DEFERRED, packages/core/src/repowise/core/agent_steer.py) reaches Claude Code two ways:

  • SessionStart hook: _handle_claude_session_start, augment_cmd/session_start.py:66. SessionStart never fires for a subagent; the code calls this "a real gap" at session_start.py:176.
  • Generated CLAUDE.md block. Absent in repos without one.

The only route to a subagent is the rule's own sentence asking the parent to "pass this rule on in any subagent brief". agent_steer.py notes models skip that.

Proposed Solution

Add a SubagentStart hook that returns AGENT_STEER_DEFERRED as hookSpecificOutput.additionalContext. Per the Claude Code hooks reference, that context goes to the subagent itself, before its first prompt. It's injected again on resume if compaction dropped it.

  • plugins/claude-code/hooks/hooks.json: add a SubagentStart entry running repowise-augment, like the SessionStart one.
  • augment_cmd/command.py: route hook_event_name == "SubagentStart" to a small handler in session_start.py:
    • Return [repowise <build>] + AGENT_STEER_DEFERRED.
    • Return nothing outside an indexed repo (same _find_repo_root + state.json check as SessionStart).
    • Skip freshness, decisions and setup lines. The parent already has them, and every line costs subagent tokens.
  • editor_integrations/claude_config.py: backfill the same entry in install_claude_code_hooks (_backfill_event) for the settings.json install route.
  • Test: a SubagentStart payload in an indexed repo emits the steer; outside one it emits nothing.

Alternatives Considered

  • Rely on "pass this rule on in any subagent brief" (status quo). Models skip it.
  • Strengthen MCP server instructions. agent_steer.py records that MCP instructions with the same text were not followed.
  • PostToolUse on the Agent tool. Fires after the subagent ran, and its context goes to the parent.

Additional Context

  • Hooks reference (code.claude.com/docs/en/hooks): SubagentStart gets agent_id and agent_type, can't block, and "can inject context into the subagent". Its matcher is the agent type.
  • Open question: match all agent types, or skip ones without repowise MCP tools? Matching all is the smallest change. A subagent without those tools just ignores the line.
  • Tool-call hooks (PostToolUse etc.) already fire inside subagents and keep separate read state via agent_id (augment_cmd/read_state.py:71). Only the steer is missing.
Dominant language
Python
Stars
7.1k
Forks
756
Avg merge
21h 5m
Merged PRs (30d)
797

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from repowise-dev/repowise

All issues in repowise-dev/repowise

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.