Skip to content
This repository was archived by the owner on Jun 8, 2026. It is now read-only.
This repository was archived by the owner on Jun 8, 2026. It is now read-only.

Port reflection-3 to Claude Code as Stop-hook plugin #137

@dzianisv

Description

@dzianisv

Context

Parent: #131 (portability verdict — Claude Code adapter declared viable).

In long CC sessions, the agent forgets project-level skill guidance (e.g. /take-ownership) and back-delegates to the user prematurely. reflection-3.ts already solves the equivalent problem in OpenCode via session.idle hook. This issue tracks porting that pattern to Claude Code.

Goal

A CC plugin that, on the Stop event:

  1. Grades whether the assistant actually finished the task (re-uses reflection-3 evaluator).
  2. If incomplete, injects a follow-up prompt via decision: "block" + additionalContext to keep the agent driving.
  3. Honors stop_hook_active to prevent infinite loops.
  4. Detects planning/action loops and back-delegation to the user as failure modes.

Success Metric

Manual smoke: open a fresh CC session in this repo, give a multi-step coding task, observe at least one Stop→inject→continue cycle where the plugin successfully re-prompts the agent. Plugin must NOT loop more than 3 times on same failure mode, and must not fire when stop_hook_active=true.

Scope

  • New: claude/ directory containing the plugin (manifest + hook + bin script)
  • Reuse: import core grading/loop-detection from a shared module extracted from reflection-3.ts (or, speed path, copy + adapt)
  • Out of scope: Codex adapter (Assess portability of OpenCode plugins to Codex and Claude Code #131 says App Server sidecar — separate issue)

Acceptance Criteria

  • .claude-plugin/plugin.json valid, installable via claude --plugin-dir
  • Stop hook injects follow-up prompt for incomplete tasks
  • stop_hook_active loop guard implemented
  • Real-feature smoke test passes (documented in .tasks/.../test-report.md)
  • Atomic commits per phase

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions