analyze-session
Skill139 starsChanged 3 months agoApache-2.0View on GitHub
Analyse and optimise a dev-workflow-v3 factory session (implementer step). Use for /analyze-session <runId>, or when asked why a factory run was slow, where the implementer's time went, or how to make the factory agent more efficient.
3 other projects use a version of this.
Adopted by
Most recently taken up by
- microsoft/microsoft-ui-xamltheir own version, first seen Nov 15, 2026
- tbhb/vale-ai-tellstheir own version, first seen Oct 11, 2026
- dabowman/Figmagenttheir own version, first seen Sep 4, 2026
Other versions3 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 3
- microsoft/microsoft-ui-xaml★ 8.6ksame name
- tbhb/vale-ai-tells★ 118same name
- dabowman/Figmagent★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository4 other files it gives its agents.
- AGENTS.mdAGENTS.md
- project-memory/AGENTS.mdAGENTS.md
- dddSkill
- role-check-and-lint-error-remediationSkill
The file
We split this skill into the rules it gives an agent
5 rules. 0 are common, 4 are distinctive, and 1 is very specific to this project.
0
Common
Most of the 3 edited versions we read keep these.
4
Distinctive
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 15
Run the stats script from the repository root:
- Very specific: line 37
Before writing anything, look at the evidence behind the biggest numbers.
- Distinctive: line 94
Prefer changes to prompts, tool wiring, budgets and harness behaviour over vague advice.
- Distinctive: line 100
Every number sits next to the thing it counts.
- Distinctive: line 103
Use more words rather than fewer.
“Common” is measured: kept by at least 6 in 10 of the 3 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Analyse a factory session
Analyse one factory run out of .factory/mastra.db and turn the numbers into
concrete efficiency improvements for the implementer step. Do not change any
factory code and do not commit as part of this skill; the deliverable is the
written analysis.
Produce the stats
Run the stats script from the repository root:
node scripts/analyze-session.mjs <runId>An optional second argument is the path to a mastra.db in another working
copy's .factory directory. When you use it, run every evidence query below
against that same database path, from that working copy.
The script writes the stats report to .factory/analysis/<runId>.md and
prints the same content. The file already has its final shape: a summary table,
the time table, the checks table, command tables, the rework table, stuck
signals and data gaps, all with named evidence and bold labels. Do not rewrite
or reformat it. Your job is to add the two analysis sections to it.
The numbers are inferred from observability spans and the stored transcript, so treat them as estimates, not measurements. Running the script again refreshes the stats tables and keeps the analysis sections that were already appended.
Investigate the causes
Before writing anything, look at the evidence behind the biggest numbers. The
transcript lives in mastra_messages (plain JSON, one row per stored message
with parts for text, reasoning and tool invocations) and spans live in
mastra_ai_spans (readable columns, truncated binary payloads — do not try to
decode input/output/attributes).
Useful queries:
# What the implementer said and did in a time slice.
# The thread is named after the issue, not the run: run `issue-501-9`
# belongs to thread `issue-501-implementer`. Use <database> as above.
sqlite3 <database> "SELECT role, createdAt, content FROM mastra_messages
WHERE thread_id='<issueNumber>-implementer' AND createdAt BETWEEN '<start>' AND '<end>'
ORDER BY createdAt"
# Span timeline for one activity type
sqlite3 <database> "SELECT name, startedAt, endedAt FROM mastra_ai_spans
WHERE threadId='<issueNumber>-implementer' AND startedAt BETWEEN '<start>' AND '<end>'
AND spanType IN ('tool_call','model_inference') ORDER BY startedAt"Also check .factory/logs/runs.log for the run's outcome and any
*-failed-request.json files for provider rejections. Note that the stored
transcript is incomplete: trimmed history and aborted turns lose tool results,
and the script says how many command executions have no recorded result.
For each headline number, name the concrete behaviour that produced it, with timestamps or command text as evidence. Do not speculate where the data does not reach; say what is unknown.
Write the analysis
The script has already created .factory/analysis/<runId>.md with the
stats. Add two sections to that file: update a section in place when it is
already there from an earlier run, and append it only when it is absent. Do not
touch the generated stats.
## What caused the numbers
One subsection per big number. The heading names the number and the cause, for
example ### Stuck: 28% of the step. Two requests that never came back. Under
it: a few short sentences, then bullets that name the evidence. Name the exact
command, file or timestamp. "A file was edited 9 times" is useless; name the
file.
## Improvement suggestions
Up to 20 subsections, numbered, ordered by expected time saved. Only suggest a change when this session's numbers back it; if fewer than 10 opportunities are evidenced, write fewer. Each one has three bullets with bold labels:
- What to do: the change.
- Why: the evidence from this session.
- What it saves: the expected effect.
Prefer changes to prompts, tool wiring, budgets and harness behaviour over vague advice.
Writing rules
- Short simple sentences. One idea per sentence.
- Every number sits next to the thing it counts.
- Label-value facts go in tables with bold labels. The script already does this; match it in the sections you write.
- Use more words rather than fewer.
Then tell the user where the file is and give the headline numbers in the chat. Suggest follow-up work; do not start implementing changes to the factory unless the user asks for that separately.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

