sona-learning-optimizer — Claude Code subagent: what it does
sona-learning-optimizer — a subagent that logs every task as a trajectory and nudges quality up by reusing similar past patterns and LoRA fine-tuning.
no license ★ 850 updated 2026-10-26
.claude/agents/sona-learning-optimizer.mdWhat sona-learning-optimizer does
Learning sits inside every run. Before the task, a hook looks up a few similar patterns, opens a trajectory in npx claude-flow sona and tags it with the agent name. After the task, a second hook scores the output, writes activation and attention vectors, closes the trajectory and starts a learning cycle when there is enough data. The agent description claims up to +55% quality.
Both hooks are shell scripts kept in the agent's frontmatter. They call npx claude-flow sona pattern find and trajectory begin/step/end, build vectors with python3 and parse JSON with jq. Those vectors are stand-ins: embeddings and activations come from a random generator seeded by a hash of the task or the output.
The hooks need npx claude-flow, jq and python3 on PATH; miss one and the learning step is skipped without an error. Quality is scored from answer length plus the number of code fences, so a long answer full of code scores high whether or not it is any good.
What it helps with
- log each task as a trajectory you can inspect later
- pull up similar past solutions before starting a new task
- score answer quality from measurable signals
- route requests to a model with quality in mind
- keep learned patterns without retraining the whole model
Example prompts for the agent
- Run
sona-learning-optimizeron the failing test and list the similar patterns it found. - Hand the schema migration to
sona-learning-optimizerand finish withnpx claude-flow sona stats. - Use
sona-learning-optimizerto fix the build and keep the trajectory so the pattern stays in the library.
How to install sona-learning-optimizer
Manually: put the files in place
.claude/agents/sona-learning-optimizer.mdFor all projects use ~/.claude/agents/. Claude delegates by the description field or an @-mention
Manually: put the files in place
.codex/agents/sona-learning-optimizer.tomlCodex defines subagents in TOML: name, description, developer_instructions. Move the Markdown text into developer_instructions by hand. For all projects use ~/.codex/agents/
Manually: put the files in place
.cursor/agents/sona-learning-optimizer.mdCursor also reads .claude/agents/
Step by step, with commands for each platform: Claude Code subagents: how to create one, call it and keep context clean
Questions about sona-learning-optimizer
How do I install sona-learning-optimizer in Claude Code?
Put the agent file at .claude/agents/sona-learning-optimizer.md. Claude picks it up from there as a subagent.
What does sona-learning-optimizer do?
It tracks each task as a trajectory: finds similar patterns beforehand, scores the result afterwards and, when the data allows, runs a learning cycle with LoRA and EWC++.
What has to be installed for the learning to work?
npx claude-flow, jq and python3 on PATH. If no trajectory was created, the post-task hook skips learning.