From digital-twin
Mine the user's own Claude Code session logs to build a behavioral profile and an installable subagent that mirrors how they actually orchestrate Claude Code. Produces a personalized PROFILE.md (+PROFILE.html with charts), a twin.md subagent, a CLAUDE.md patch, a per-user gotchas catalog, and a canonical numbers source-of-truth — all from local jsonl logs. Local pipeline runs in ~20 seconds on a 10k-session corpus; the three LLM-bound phases (deep-read agents, profile extraction, and behavioral-spec extraction) dominate wall-clock. Use when the user says any of: "build a digital twin of me", "make a personal agent from my prompts", "analyze my Claude Code usage", "mine my session logs", "I want a twin agent", "build an agent that acts like me", "encode my workflow as a subagent", "create a personalized orchestrator", "build a CLAUDE.md from my history", "what does my Claude Code usage look like", "show me my prompt patterns". This skill MUST be consulted for those requests because no other skill or generic agent can produce a personalized orchestrator from log mining — generic best-practice agents won't capture the user's specific conventions, vocabulary, project glossary, pushback triggers, or recovery cycles. Even if the user phrases the request indirectly ("analyze my workflow", "build a CLAUDE.md for me", "what's my style?") consult this skill — the output is materially different from a generic agent because it quotes the user's actual prompts, encodes their actual memory rules, and matches their actual voice.
How this skill is triggered — by the user, by Claude, or both
Slash command
/digital-twin:digital-twinThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Build a personalized Claude Code subagent from the user's own session logs.
references/claude-patch-template.mdreferences/extraction-schema.mdreferences/insights-schema.jsonreferences/methodology.mdreferences/profile-template.htmlreferences/profile-template.mdreferences/prompts/encoded-rules-deep-read.mdreferences/prompts/failure-recovery-deep-read.mdreferences/prompts/insights-extraction.mdreferences/prompts/orchestration-deep-read.mdreferences/prompts/planning-style-deep-read.mdreferences/prompts/quality-deep-read.mdreferences/prompts/twin-spec-extraction.mdreferences/prompts/workflow-deep-read.mdreferences/subagent-template.mdreferences/twin-spec-schema.jsonreferences/visualization/charts.pyscripts/assistant-turn-mining.pyscripts/evaluate-twin.pyscripts/extract-corpus.pyBuild a personalized Claude Code subagent from the user's own session logs.
| Artifact | Path | Purpose |
|---|---|---|
| Profile (md) | ~/.claude/digital-twin/PROFILE.md | Behavioral analysis with ASCII charts |
| Profile (html) | ~/.claude/digital-twin/PROFILE.html | Same content, inline SVG charts, self-contained |
| Subagent | ~/.claude/agents/twin.md | Installable user-substituting orchestrator |
| CLAUDE.md patch | ~/.claude/digital-twin/CLAUDE-md-patch.md | Global defaults addendum |
| CLAUDE rules | ~/.claude/digital-twin/rules/*.md | Compact installable substitution/preference/workflow/verification/recovery rules |
| Gotchas card | ~/.claude/digital-twin/gotchas.md | Per-user gotchas catalog |
| Canonical numbers | ~/.claude/digital-twin/numbers.md | Verification source-of-truth |
| Raw corpora | ~/.claude/digital-twin/corpora/*.jsonl | For re-analysis |
/digital-twin:init, /digital-twin:update, /digital-twin:status, or /digital-twin:propose-rulesscripts/extract-corpus.py --count-only to verify and warn.The full methodology lives in references/methodology.md — read it before driving a run. The summary:
| Phase | Wall-clock (measured) | What runs |
|---|---|---|
| 1. Setup | seconds | Confirm ~/.claude/projects/ exists, count files, confirm identity, ask for UTC offset |
| 2. Extract | ~5 sec / 10k sessions | scripts/extract-corpus.py |
| 3. Quantitative | ~10 sec | scripts/quantitative.py (~8 s), scripts/temporal.py (~1 s) — run in parallel |
| 4. Deep sources | ~5 sec | memory-inventory.py, plan-inventory.py, assistant-turn-mining.py, optional pr-comment-mining.sh — all local, run in parallel before the LLM reports |
| 5. Qualitative agents | LLM-bound, varies | 6 general-purpose agents in parallel writing free-form Markdown deep reads to analysis/reports/. Wall-clock depends on model latency and parallel-dispatch overhead. |
| 5.5. Insights extraction | 3-10+ min | Single Sonnet call (~180 KB input) distills the 6 reports + stats into 7 structured JSON files. Default timeout is 15 min and can be raised with --timeout; falls back to Tier 2 if it overruns. |
| 5.6. Twin spec extraction | 3-10+ min | Single Sonnet call distills reports + insights + stats + deep-source inventories into analysis/twin-spec.json, the source of truth for the user-substituting replacement agent |
| 6. Synthesize | <1 sec | scripts/synthesize.py produces PROFILE.md + PROFILE.html (card-styled) + compact twin.md + CLAUDE.md patch + generated rule files |
Local pipeline total (Phases 2, 3, 4, 6): ~20 seconds on a 10k-session corpus. The LLM-bound phases (5, 5.5, and 5.6) dominate wall-clock; their cost is the cost of the whole run.
Three-tier robustness in synthesize.py: if Phase 5.5 insights JSON is present, profile cards render from rich agent-derived content (Tier 1). If only Phase 5 reports exist, cards fall back to rule-based content scraped from numbers + reports (Tier 2). If Phase 5 was skipped entirely, sections show _pending_ markers but the profile still completes (Tier 3). The replacement agent is stricter: if analysis/twin-spec.json is missing or invalid, twin.md is generated with an explicit incomplete-spec warning.
The /digital-twin:init slash command orchestrates all six phases — prefer it over running scripts manually. See commands/init.md for the exact orchestration sequence.
Phases 2, 3, 4, and 6 are pure script invocations. Phase 5 is different: you (the model) dispatch 6 general-purpose subagents in one message, each filled in from a template at references/prompts/:
orchestration-deep-read.md — how the user delegatesworkflow-deep-read.md — issue → plan → impl → verify → ship lifecyclequality-deep-read.md — pushback, conventions, voiceencoded-rules-deep-read.md — memory rule surveyplanning-style-deep-read.md — plan archetypesfailure-recovery-deep-read.md — convergence pairsEach prompt has {{USER_NAME}}, {{PROMPT_COUNT}}, {{CORPUS_PATH}}, etc. placeholders. Fill them from numbers.json (produced in Phase 3) and the deep-source outputs (produced in Phase 4) before dispatch. Save each agent's report to ~/.claude/digital-twin/analysis/reports/<angle>.md so the synthesizer in Phase 6 can pick them up.
If Phase 5 is skipped, synthesize.py still produces a working profile — the per-angle sections render as _pending_ and the synthesizer's own narrative builders fill the headline / what-works / friction / suggestions sections from the quantitative data alone.
| Command | Purpose |
|---|---|
/digital-twin:init | Full first-time run (Phases 1-6) |
/digital-twin:update | Re-run Phases 2-6 against newer logs |
/digital-twin:status | Show last-run state + drift since |
/digital-twin:propose-rules | Review pushback-detected rule proposals |
~/.claude/projects/.claude -p, and (c) Phase 5.6 makes one behavioral-spec extraction call via claude -p. All ride the same auth you already use; no Anthropic API key required unless extract-insights.py --allow-sdk-fallback is explicitly enabled.gh api for PR comment mining only — skipped gracefully if gh isn't authenticated./digital-twin:propose-rules.API spend is from three Sonnet-backed LLM steps:
update when cached reports are reused.First run total: ~$5-9. Update without re-running agents: ~$1. Pushback detector (per-turn, if hooked): essentially free (filesystem scan only).
These are upper-bound estimates from Sonnet pricing on the v0.1 corpus shape. Lighter corpora (~5k prompts) cost proportionally less.
/digital-twin:propose-rules review._no evidence_ marker.See references/methodology.md § "Roadmap". Current release is v0.4 (substitution contract). Next: log adapters for Cursor / Aider / Codex CLI (v0.5), team profiles (v0.6), self-updating twin (v0.7), and v1.0 stability guarantees.
Guides creation, editing, and verification of skills for AI coding agents using test-driven development with subagent scenarios. Use when authoring or debugging skills.
npx claudepluginhub danielbentes/digital-twin --plugin digital-twin