Reflection worker

From oimiragieo/agent-studio · View interactive version

Reflection worker is an AI agent skill from the GitHub repository oimiragieo/agent-studio. Fixes reflection system, evolution triggers, token reporting, and hook registration

How to use this skill

Skill file

Reflection Worker

NOTE: Startup and cleanup are handled by worker-base. This skill defines the WORK PROCEDURE.

When to Use This Skill

Features involving:

Work Procedure

  1. Read the feature description and CTO Directive #2 from AGENTS.md.
  1. For score tracker work: Before ANY changes to reflection-score-tracker.cjs:
  1. Write tests first (red):
  1. Implement the fix (green):
  1. For hook registration: When registering hooks in settings.json:
  1. For token reporting: When fixing post-pipeline-token-report.cjs:
  1. For TokenAccountant persistence:
  1. Run all reflection-related tests:

```

node --test tests/hooks/reflection-*.test.cjs

node --test tests/lib/reflection-score-tracker.test.cjs

```

  1. Run broader suites for regression check:

```

pnpm test:framework

```

  1. Commit with descriptive message.

Example Handoff

{
  "salientSummary": "Fixed reflection-score-tracker.cjs: added defensive normalization (scores <= 1.0 multiplied by 10), calibrated LOW_SCORE_THRESHOLD to 4.0 (matching Critical Fail < 0.4 rubric = 4.0 on 1-10 scale). Registered force-step0-execution.cjs and reflection-data-aggregator.cjs in settings.json. Fixed token report to use structural pipelineComplete detection. Added disk persistence to TokenAccountant with atomic writes.",
  "whatWasImplemented": "Score normalization in reflection-score-tracker.cjs handles 0-1 and 1-10 scales. Two hooks registered. Token report uses metadata.pipelineComplete as primary signal. TokenAccountant persists to .claude/context/metrics/token-usage.json with write-to-temp+rename.",
  "whatWasLeftUndone": "",
  "verification": {
    "commandsRun": [
      {
        "command": "node --test tests/lib/reflection-score-tracker.test.cjs",
        "exitCode": 0,
        "observation": "All tests pass including both scale normalization"
      },
      { "command": "pnpm test:framework", "exitCode": 0, "observation": "0 failures" }
    ],
    "interactiveChecks": []
  },
  "tests": {
    "added": [
      {
        "file": "tests/lib/reflection-score-tracker.test.cjs",
        "cases": [
          { "name": "normalizes 0-1 scores to 1-10", "verifies": "CTO directive #2" },
          { "name": "passes through 1-10 scores unchanged", "verifies": "1-10 scale handling" },
          { "name": "handles mixed scale entries", "verifies": "defensive normalization" }
        ]
      }
    ],
    "coverage": "Score tracker, token report, and accountant persistence all covered"
  },
  "discoveredIssues": []
}

When to Return to Orchestrator

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.