{"id":50333856,"url":"https://github.com/danielbentes/digital-twin","last_synced_at":"2026-05-29T12:05:23.702Z","repository":{"id":357923622,"uuid":"1236080758","full_name":"danielbentes/digital-twin","owner":"danielbentes","description":"Mine your Claude Code session logs into a personalized profile, twin sub-agent, and CLAUDE.md patch — local-first, your logs never leave your machine.","archived":false,"fork":false,"pushed_at":"2026-05-14T20:27:46.000Z","size":361,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-05-14T22:34:28.563Z","etag":null,"topics":["anthropic","claude-code","claude-code-plugin","developer-tools","digital-twin","log-mining","personalization","plugin","self-analysis","sub-agent"],"latest_commit_sha":null,"homepage":"https://github.com/danielbentes/digital-twin","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/danielbentes.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-05-11T23:49:25.000Z","updated_at":"2026-05-11T23:54:38.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/danielbentes/digital-twin","commit_stats":null,"previous_names":["danielbentes/digital-twin"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/danielbentes/digital-twin","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielbentes%2Fdigital-twin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielbentes%2Fdigital-twin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielbentes%2Fdigital-twin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielbentes%2Fdigital-twin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/danielbentes","download_url":"https://codeload.github.com/danielbentes/digital-twin/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielbentes%2Fdigital-twin/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33650723,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-05-29T02:00:06.066Z","response_time":107,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["anthropic","claude-code","claude-code-plugin","developer-tools","digital-twin","log-mining","personalization","plugin","self-analysis","sub-agent"],"created_at":"2026-05-29T12:05:23.166Z","updated_at":"2026-05-29T12:05:23.690Z","avatar_url":"https://github.com/danielbentes.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# digital-twin\n\n\u003e A Claude Code plugin that mines your own session logs to build a digital twin: a profile of how you actually work, a user-substituting orchestration sub-agent, and a CLAUDE.md patch you can drop into any new project.\n\nLocal extraction/statistics/rendering stay on your machine. The LLM-bound phases use your existing Claude Code auth and can send corpus-derived evidence to Claude: deep-read agents, profile-insight extraction, and compact behavioral `twin-spec.json` extraction. No plugin telemetry.\n\n---\n\n## What it does\n\nThe plugin walks `~/.claude/projects/*/*.jsonl` (every Claude Code session you've ever had) and produces six artifacts:\n\n| Artifact | What it is |\n|---|---|\n| `PROFILE.md` | An insights-style report: how you orchestrate, where you push back, what plans you write, what rules you've encoded. Includes ASCII charts. |\n| `PROFILE.html` | The same report with inline SVG charts. Self-contained — open in any browser. |\n| `~/.claude/agents/twin.md` | A compact operational delegate rendered from `analysis/twin-spec.json`. Invocable as `@twin` (or via the `Agent` tool) to guide work the way you would. |\n| `rules/*.md` | Generated CLAUDE rule files for substitution authority, preferences, workflows, verification, and recovery. |\n| `CLAUDE-md-patch.md` | A short install guide that imports or symlinks the generated rules. |\n| `gotchas.md` | Seed list of pushback patterns from your own corpus. Editable. |\n| `numbers.md` | Canonical metrics — source of truth for everything else. |\n\nIt also runs an **opt-in self-update loop**: every so often, run `/digital-twin:propose-rules` and the plugin will queue candidate memory rules drafted from pushbacks the detector saw but you haven't encoded yet. You approve each one explicitly — nothing is auto-written.\n\n---\n\n## Install\n\n### From the marketplace (recommended)\n\nThis repo is its own single-plugin marketplace — one `add` + one `install`:\n\n```\n/plugin marketplace add danielbentes/digital-twin\n/plugin install digital-twin@digital-twin\n```\n\nThe first `digital-twin` is the plugin name; the `@digital-twin` is the marketplace name. They happen to be the same because this repo is both the plugin and its catalog.\n\n### From a local checkout (for development)\n\n```bash\ngit clone https://github.com/danielbentes/digital-twin ~/code/digital-twin\nclaude --plugin-dir ~/code/digital-twin\n```\n\nUseful if you want to edit the skill while running it.\n\n### Verify the install\n\n```\n/plugin list\n```\n\nYou should see `digital-twin` enabled. After install, invoke any of the slash commands:\n\n```\n/digital-twin:init           # first-time build (local pipeline ~20 sec; 2 LLM phases dominate wall-clock)\n/digital-twin:update         # refresh against new logs (re-runs the local pipeline + extraction)\n/digital-twin:status         # show what's known about you so far\n/digital-twin:propose-rules  # review pending pushback-derived rule proposals\n```\n\n### Update\n\nWhen a new version ships, refresh and reinstall:\n\n```\n/plugin marketplace update digital-twin\n/plugin install digital-twin@digital-twin\n```\n\nOr enable auto-update in your Claude Code settings.\n\n---\n\n## Quickstart (manual, without the slash command)\n\nIf you'd rather drive the pipeline yourself:\n\n```bash\nSKILL=~/code/digital-twin/skills/digital-twin\nOUT=/tmp/dt-run\n\n# 1. Extract corpus from all session logs\npython3 $SKILL/scripts/extract-corpus.py --out $OUT\n\n# 2. Quantitative pass (vocab, slash share, languages, ...)\npython3 $SKILL/scripts/quantitative.py \\\n  --corpus $OUT/corpus.jsonl \\\n  --out-json $OUT/numbers.json --out-md $OUT/numbers.md\n\n# 3. Temporal pass (hour/day histogram, recovery cycles, drift)\npython3 $SKILL/scripts/temporal.py \\\n  --timestamped $OUT/timestamped.jsonl \\\n  --out-json $OUT/temporal.json --out-md $OUT/temporal.md \\\n  --tz-offset-hours 2   # adjust to your local UTC offset\n\n# 4. Memory + plan inventories\npython3 $SKILL/scripts/memory-inventory.py \\\n  --out-json $OUT/memory-inventory.json --out-md $OUT/rules.md\npython3 $SKILL/scripts/plan-inventory.py \\\n  --out-json $OUT/plan-inventory.json --out-md $OUT/plans.md \\\n  --search-dir ~/code   # add directories where you keep .decisions/ folders\n\n# 5. Convergence analysis (assistant-turn → user-reply pairs)\npython3 $SKILL/scripts/assistant-turn-mining.py \\\n  --out-json $OUT/convergence-pairs.json \\\n  --out-md $OUT/pushback-triggers.md\n\n# 6. (Optional) PR comment style — needs `gh` CLI authenticated\n$SKILL/scripts/pr-comment-mining.sh --out-json $OUT/pr-comments.json\n\n# 7. Behavioral twin spec (default for replacement-agent output).\n# If Phase 5 reports or Phase 5.5 insights exist, this writes twin-spec.json.\n# If you are running this local-only quickstart before deep-read reports exist,\n# --allow-empty keeps the profile pipeline moving and synthesis emits a degraded\n# twin.md warning instead of pretending the replacement agent is complete.\nmkdir -p $OUT/reports\npython3 $SKILL/scripts/extract-twin-spec.py \\\n  --analysis-dir $OUT --reports-dir $OUT/reports \\\n  --out-json $OUT/twin-spec.json --user-name \"$USER\" \\\n  --allow-empty\n\n# 8. Synthesize → PROFILE.md, PROFILE.html, twin.md, rules/, CLAUDE-md-patch.md\npython3 $SKILL/scripts/synthesize.py \\\n  --analysis $OUT --reports $OUT/reports \\\n  --out $OUT/out --agents-dir $OUT/agents \\\n  --user-name \"$USER\"\n\nopen $OUT/out/PROFILE.html  # macOS — or xdg-open on Linux\n```\n\nThe qualitative deep-read phase (6 parallel agents producing 1500-2500 word reports), Phase 5.5 (profile-card extraction), and Phase 5.6 (behavioral twin-spec extraction) are what `/digital-twin:init` orchestrates. Without insights, `synthesize.py` still renders profile charts via Tier 2/3 fallbacks. Without `twin-spec.json`, it writes an explicitly degraded `twin.md` warning instead of pretending the agent can replace you.\n\n---\n\n## Self-updating loop\n\nThe plugin includes a **pushback detector** that watches `(assistant-turn, user-reply)` pairs incrementally. When it sees a pushback that isn't already covered by an existing memory rule or principle, it drafts a candidate judgment correction and queues it at `~/.claude/digital-twin/proposed-rules/`.\n\n```bash\n# Run the detector manually (incremental — only new sessions since last run)\npython3 ~/code/digital-twin/skills/digital-twin/scripts/pushback-detector.py\n\n# Review pending proposals interactively\n/digital-twin:propose-rules\n```\n\nThe detector **never writes to memory directly**. Every approval is explicit; rejected proposals move to an `archive/` subdirectory for audit.\n\nYou can wire the detector to a Claude Code `PostToolUse` hook so it runs after every turn — see `examples/hook-config.json` for a sample (not auto-installed).\n\n---\n\n## What you'll learn\n\nSample insights the plugin surfaces from a real corpus (~20k prompts):\n\n- **Convergence shape** — what % of your replies are first-word approvals (`go`, `ship`) vs explicit pushback (`stop`, `wait`) vs implicit pushback (long replies with `actually`/`but`/`instead` markers).\n- **Recovery cost** — how many turns it takes you to return to approval after a pushback (median and p90).\n- **Plan rigor over time** — does your out-of-scope adoption rise, fall, or stay flat as you write more plans?\n- **Vocabulary drift** — which steering verbs are rising vs fading in your most recent quarter of work.\n- **Top encoded rules** — every feedback-type memory file across all your projects, deduplicated and grouped.\n\nThe HTML version embeds inline SVG charts: hour-of-day bar chart with peak hour highlighted, day-of-week histogram, convergence donut, and plan-rigor drift comparison. The encoded-rules section renders each memory rule as a card grouped by project, with Why and How-to-apply sections parsed out of the rule body.\n\n---\n\n## Privacy\n\n- **Local phases stay local.** The Python extraction/statistics/rendering scripts read from `~/.claude/projects/` and write to `~/.claude/digital-twin/` + `~/.claude/agents/twin.md`; they do not upload files on their own.\n- **LLM phases send corpus-derived evidence to Claude.** Phase 5 dispatches 6 deep-read agents, Phase 5.5 makes one profile-insights extraction call via `claude -p`, and Phase 5.6 makes one behavioral-spec extraction call via `claude -p`. These use your existing Claude Code auth and can include selected prompts, reports, quotes, stats, and memory-derived evidence. `extract-insights.py` only uses the Anthropic SDK/API-key fallback when you explicitly pass `--allow-sdk-fallback`.\n- **Generated HTML is self-contained.** `PROFILE.html` uses inline CSS/SVG and local system fonts only.\n- **Optional `pr-comment-mining.sh`** calls `gh` (your own CLI) and skips gracefully if unauthenticated.\n- **No plugin telemetry. No analytics. No phone-home outside the explicit Claude/GitHub calls above.**\n\nYour `private/` directory in this repo (if present) is gitignored — personal corpora and intermediate analysis live there.\n\n---\n\n## Customizing the twin\n\nThe synthesized `twin.md` sub-agent is rendered from `analysis/twin-spec.json`, not from a raw memory dump. The 6 deep-read agents write free-form narrative to `analysis/reports/`; Phase 5.5 (`extract-insights.py`) distills profile cards into `analysis/insights/`; Phase 5.6 (`extract-twin-spec.py`) distills substitution authority, principles, trust behavior, agent supervision, and operational behavior into `analysis/twin-spec.json`. `synthesize.py` also emits `rules/substitution.md`, `rules/preferences.md`, `rules/workflows.md`, `rules/verification.md`, and `rules/recovery.md` for CLAUDE.md installation.\n\nThe CLAUDE.md patch is intended to be edited before you commit it — it's a starting point, not a finished doc.\n\n---\n\n## FAQ\n\n**Q: How much does `/digital-twin:init` cost?**\nA: ~$5-9 for a first run. Breakdown: 6 deep-read agents × ~80k input + ~12k output ≈ 540k tokens (~$4-8 Sonnet) plus two ~$0.50-1 extraction calls. `update` skips the agents by default when cached reports are reused, so it's roughly the two extraction calls.\n\n**Q: How long does `/digital-twin:init` take?**\nA: The local pipeline (extract → quantitative → temporal → memory/plan/convergence → synthesize) runs in **~20 seconds** on a 10k-session corpus. The LLM-bound phases dominate everything else: Phase 5 (6 parallel deep-read agents) is variable based on model latency, Phase 5.5 extracts profile insights, and Phase 5.6 extracts the behavioral twin spec. There's no useful fixed total — depends on agent dispatch.\n\n**Q: Can I run it without the deep-read agents?**\nA: Yes — run the manual pipeline above through step 6, skip step 7, then run step 8. You get a profile with the analytical scaffolding, charts, and rule-based card content (Tier 2) plus an explicitly degraded twin warning. Run Phase 5 + 5.5 + 5.6 later to generate the replacement-agent spec.\n\n**Q: Does it work with non-English session content?**\nA: Yes — the corpus extractor is encoding-agnostic. The quantitative pass detects dominant non-English language (Norwegian, German, Spanish, French currently). Heuristics will degrade gracefully on other languages.\n\n**Q: Is the pushback detector active by default?**\nA: No. You run it manually or wire it to a hook (sample in `examples/hook-config.json`). The detector itself is incremental and stateful — it tracks the byte offset of the last line it processed in each session file.\n\n**Q: Can I share my `PROFILE.html`?**\nA: Yes, but it contains your project names, top steering verbs, and possibly memory-file content quoted verbatim. Review before sharing publicly. The synthesizer does not anonymize.\n\n---\n\n## Roadmap\n\n- **v0.3** — Behavioral Twin v1: `twin-spec.json`, compact subagent rendering, generated CLAUDE rules, deterministic eval harness, CI, security hardening, real-corpus validation.\n- **v0.4 (current)** — Substitution contract: `constitution`, `substitution_contract`, `trust_policy`, `agent_supervision_policy` first-class spec sections; principle-rich rules; destructive-verb deny-list on legacy authority; `--strict-substitution` flag; user-name sanitization; principled pushback proposal scaffolds; held-out multi-agent eval coverage.\n- **v0.5** — Cursor adapter (Cursor's chat history has similar structure); split `synthesize.py` into smaller modules.\n- **v0.6** — Team profiles; PostToolUse hook bundled (currently sample-only).\n- **v1.0** — Comparison mode (you vs another team's profile) and team-level twin synthesis.\n\n---\n\n## License\n\nMIT — see [LICENSE](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanielbentes%2Fdigital-twin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdanielbentes%2Fdigital-twin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanielbentes%2Fdigital-twin/lists"}