# sona-learning-optimizer

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.

- subagent · `type=agent` · Claude Code, Codex, Cursor · ★ 850 repo stars
- Author: ruvnet
- License: not stated · policy=link-only · description only; the file stays with the author
- Source: https://github.com/ruvnet/agentic-flow/tree/HEAD/agentic-flow/.claude/agents/sona/sona-learning-optimizer.md
- Updated: 2026-10-26
- Security check: automated, 2026-11-16 (text) — no signs of malicious code found.
- HTML: https://affpapa.org/en/nevibecode/agents/sona-learning-optimizer

## What it 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.

## Install

### Claude Code (native platform)

**Manually: put the files in place**
- File: `.claude/agents/sona-learning-optimizer.md` — For all projects use ~/.claude/agents/. Claude delegates by the description field or an @-mention

### Codex

**Manually: put the files in place**
- File: `.codex/agents/sona-learning-optimizer.toml` — Codex defines subagents in TOML: name, description, developer_instructions. Move the Markdown text into developer_instructions by hand. For all projects use ~/.codex/agents/

### Cursor

**Manually: put the files in place**
- File: `.cursor/agents/sona-learning-optimizer.md` — Cursor also reads .claude/agents/

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/ruvnet/agentic-flow/tree/HEAD/agentic-flow/.claude/agents/sona/sona-learning-optimizer.md

## When to use it
- 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
- Run `sona-learning-optimizer` on the failing test and list the similar patterns it found.
- Hand the schema migration to `sona-learning-optimizer` and finish with `npx claude-flow sona stats`.
- Use `sona-learning-optimizer` to fix the build and keep the trajectory so the pattern stays in the library.

## Similar
- [continual-learning](https://affpapa.org/en/nevibecode/skills/continual-learning.md) — skill · 79 installs
- [skillopt-sleep](https://affpapa.org/en/nevibecode/plugins/skillopt-sleep.md) — plugin · ★ 30251 repo stars
- [explore-code](https://affpapa.org/en/nevibecode/skills/explore-code.md) — skill · 362900 installs
- [swarm-advanced](https://affpapa.org/en/nevibecode/skills/swarm-advanced.md) — skill · 1200 installs
- [V3 Deep Integration](https://affpapa.org/en/nevibecode/skills/v3-deep-integration.md) — skill · 1100 installs
- [p-image](https://affpapa.org/en/nevibecode/skills/p-image.md) — skill · 14500 installs

From the same set: [ruvnet/agentic-flow](https://affpapa.org/en/nevibecode/by/ruvnet/agentic-flow.md) — 76 cards

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
