<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: megaphone</title>
    <description>The latest articles on DEV Community by megaphone (@megaphone).</description>
    <link>https://dev.to/megaphone</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3883168%2F25864556-bf6c-404f-9e7d-fb29d04c150d.png</url>
      <title>DEV Community: megaphone</title>
      <link>https://dev.to/megaphone</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/megaphone"/>
    <language>en</language>
    <item>
      <title>I built KIOKU — an OSS memory system for Claude Code</title>
      <dc:creator>megaphone</dc:creator>
      <pubDate>Fri, 17 Apr 2026 13:22:00 +0000</pubDate>
      <link>https://dev.to/megaphone/i-built-kioku-an-oss-memory-system-for-claude-code-3mhd</link>
      <guid>https://dev.to/megaphone/i-built-kioku-an-oss-memory-system-for-claude-code-3mhd</guid>
      <description>&lt;h2&gt;
  
  
  The Problem
&lt;/h2&gt;

&lt;p&gt;I use Claude Code every day. It's an incredible tool — but it has one major weakness.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Every new session starts from zero.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The project context I explained yesterday? Gone. The design decision we debated for 30 minutes? Forgotten. The tech stack rationale? I'm explaining it again.&lt;/p&gt;

&lt;p&gt;I got tired of repeating myself, so I built a memory system.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;KIOKU — Memory for Claude Code&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/megaphone-tokyo/kioku" rel="noopener noreferrer"&gt;https://github.com/megaphone-tokyo/kioku&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;"KIOKU" means "memory" in Japanese. The concept: a "second brain" that grows as you use Claude Code, and feeds your past knowledge back into every new session.&lt;/p&gt;

&lt;h2&gt;
  
  
  Inspiration
&lt;/h2&gt;

&lt;p&gt;The core idea comes from Andrej Karpathy's &lt;a href="https://gist.github.com/karpathy/442a6bf555914893e9891c11519de94f" rel="noopener noreferrer"&gt;LLM Wiki gist&lt;/a&gt; — the concept of growing a structured wiki from LLM conversations.&lt;/p&gt;

&lt;p&gt;When I read it, I thought: "This is exactly what I need." But the gist is a concept, not an implementation. So I built it specifically for Claude Code, with full automation.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Happens When You Install KIOKU
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;🗣️  You chat with Claude Code as usual
         ↓  (everything is recorded automatically — you do nothing)
📝  Session logs saved locally
         ↓  (a scheduled job asks AI to read the logs and extract knowledge)
📚  Wiki grows with each session — concepts, decisions, patterns
         ↓  (synced via Git)
☁️  GitHub keeps your Wiki backed up and shared across machines
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The key point: &lt;strong&gt;you don't do anything&lt;/strong&gt;. No note-taking, no log management. Just use Claude Code normally, and the wiki grows in the background.&lt;/p&gt;

&lt;h2&gt;
  
  
  Architecture
&lt;/h2&gt;

&lt;p&gt;KIOKU has a 4-layer design.&lt;/p&gt;

&lt;h3&gt;
  
  
  L0: Auto-Capture
&lt;/h3&gt;

&lt;p&gt;Claude Code's Hook system captures session I/O. I use four hook events:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;UserPromptSubmit&lt;/code&gt; — your prompts&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;Stop&lt;/code&gt; — Claude's responses&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;PostToolUse&lt;/code&gt; — tool execution results&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;SessionEnd&lt;/code&gt; — session finalization&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These write Markdown logs to &lt;code&gt;session-logs/&lt;/code&gt; in your Obsidian Vault. The hook script is a zero-dependency &lt;code&gt;.mjs&lt;/code&gt; file with no network access whatsoever.&lt;/p&gt;

&lt;h3&gt;
  
  
  L1: Structuring
&lt;/h3&gt;

&lt;p&gt;A scheduled job (macOS LaunchAgent / Linux cron) runs periodically. It feeds unprocessed logs to &lt;code&gt;claude -p&lt;/code&gt;, which generates structured wiki pages:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Concept pages&lt;/strong&gt; — technical concepts and patterns&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Project pages&lt;/strong&gt; — project-specific context, tech stack, design principles&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Decision pages&lt;/strong&gt; — why a specific decision was made (with context and rationale)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Session analyses&lt;/strong&gt; — per-session knowledge extraction&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  L2: Integrity Checks
&lt;/h3&gt;

&lt;p&gt;Monthly health checks scan the entire wiki. Broken wikilinks, missing frontmatter, orphaned pages — all detected and reported in &lt;code&gt;wiki/lint-report.md&lt;/code&gt;. Automatic secret leak detection is included here too.&lt;/p&gt;

&lt;h3&gt;
  
  
  L3: Sync
&lt;/h3&gt;

&lt;p&gt;The Vault itself is a Git repository. &lt;code&gt;SessionStart&lt;/code&gt; runs &lt;code&gt;git pull&lt;/code&gt;, &lt;code&gt;SessionEnd&lt;/code&gt; runs &lt;code&gt;git commit &amp;amp;&amp;amp; git push&lt;/code&gt;. This syncs the wiki across machines via a GitHub private repo.&lt;/p&gt;

&lt;p&gt;Crucially, &lt;strong&gt;session-logs/ never reach Git&lt;/strong&gt;. They're excluded via &lt;code&gt;.gitignore&lt;/code&gt; and stay local per machine. Only the distilled &lt;code&gt;wiki/&lt;/code&gt; is shared.&lt;/p&gt;

&lt;h3&gt;
  
  
  Wiki Context Injection — The Core
&lt;/h3&gt;

&lt;p&gt;This is the heart of KIOKU.&lt;/p&gt;

&lt;p&gt;At &lt;code&gt;SessionStart&lt;/code&gt;, &lt;code&gt;wiki/index.md&lt;/code&gt; is injected into the system prompt. This means Claude starts every new session already knowing what you've worked on before.&lt;/p&gt;

&lt;p&gt;Design decisions from yesterday? Already in Claude's head. Your project's tech stack? No need to explain again.&lt;/p&gt;

&lt;h2&gt;
  
  
  Technical Deep Dives
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Secret Masking
&lt;/h3&gt;

&lt;p&gt;This is where I spent the most effort.&lt;/p&gt;

&lt;p&gt;Claude Code sessions can contain API keys and tokens in prompts and tool output. Logging these raw would be a security risk.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;session-logger.mjs&lt;/code&gt; implements regex-based masking for tokens from:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Anthropic / OpenAI / GitHub / AWS&lt;/li&gt;
&lt;li&gt;Slack / Vercel / npm / Stripe&lt;/li&gt;
&lt;li&gt;Supabase / Firebase / Azure&lt;/li&gt;
&lt;li&gt;Bearer / Basic auth tokens&lt;/li&gt;
&lt;li&gt;URL-embedded credentials&lt;/li&gt;
&lt;li&gt;PEM private keys&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Detected tokens are replaced with &lt;code&gt;***&lt;/code&gt; before being written to disk.&lt;/p&gt;

&lt;p&gt;However, regex masking isn't perfect. New token formats from new services can slip through. That's why there's a secondary defense: &lt;code&gt;scan-secrets.sh&lt;/code&gt; runs monthly to detect masking failures.&lt;/p&gt;

&lt;h3&gt;
  
  
  .gitignore Guard
&lt;/h3&gt;

&lt;p&gt;Excluding &lt;code&gt;session-logs/&lt;/code&gt; in &lt;code&gt;.gitignore&lt;/code&gt; isn't enough on its own.&lt;/p&gt;

&lt;p&gt;Before every &lt;code&gt;git commit&lt;/code&gt; at SessionEnd, KIOKU &lt;strong&gt;verifies&lt;/strong&gt; that &lt;code&gt;.gitignore&lt;/code&gt; still contains &lt;code&gt;session-logs/&lt;/code&gt;. If someone accidentally modifies &lt;code&gt;.gitignore&lt;/code&gt;, this guard prevents session logs from being pushed to GitHub.&lt;/p&gt;

&lt;h3&gt;
  
  
  Hook Recursion Prevention
&lt;/h3&gt;

&lt;p&gt;This one bit me hard.&lt;/p&gt;

&lt;p&gt;The auto-ingest job calls &lt;code&gt;claude -p&lt;/code&gt; to process logs. But &lt;code&gt;claude -p&lt;/code&gt; is itself a Claude Code session, which triggers hooks. So you get logs of "the session that processes logs," which triggers another processing attempt... infinite recursion.&lt;/p&gt;

&lt;p&gt;The fix is a double guard:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Env var guard&lt;/strong&gt;: Set &lt;code&gt;KIOKU_NO_LOG=1&lt;/code&gt; before calling &lt;code&gt;claude -p&lt;/code&gt;. The hook script checks this variable and returns early.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;cwd check&lt;/strong&gt;: If the current working directory is inside the Vault, skip logging.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If either guard fails, the other catches it.&lt;/p&gt;

&lt;h3&gt;
  
  
  LLM Permission Restriction
&lt;/h3&gt;

&lt;p&gt;The &lt;code&gt;claude -p&lt;/code&gt; calls in auto-ingest and auto-lint run with &lt;code&gt;--allowedTools Write,Read,Edit&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Bash is not allowed.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Wiki generation only needs file read/write. Allowing Bash would create unnecessary risk — if there were ever a prompt injection issue, the blast radius would be much larger.&lt;/p&gt;

&lt;h2&gt;
  
  
  Real-World Usage
&lt;/h2&gt;

&lt;p&gt;I run KIOKU on a two-Mac setup: a MacBook (primary dev machine) and a Mac mini.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;session-logs/&lt;/code&gt; stays local per machine&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;wiki/&lt;/code&gt; syncs via Git&lt;/li&gt;
&lt;li&gt;Ingest schedules are offset by 30 minutes to avoid Git conflicts (MacBook: 7:00/13:00/19:00, Mac mini: 7:30/13:30/19:30)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;After running it for several weeks, &lt;strong&gt;the difference is bigger than I expected.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Where it helped most:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Design decision continuity&lt;/strong&gt;: "Yesterday we chose Y over X for performance reasons" carries over automatically to the next session&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;No more tech stack explanations&lt;/strong&gt;: The project's technology context is already there&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Failure memory&lt;/strong&gt;: "We tried approach Z before and it didn't work because..." is recorded and available&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What I'd Do Differently
&lt;/h2&gt;

&lt;p&gt;Looking back, a few things I'd change:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Start with a simpler wiki schema&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I over-engineered the note templates from the start — concept pages, project pages, decision pages, all with detailed templates. In hindsight, starting with "just dump everything as notes" and organizing later would have been more natural.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Ingest prompt tuning matters more than I thought&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Wiki page quality depends almost entirely on the ingest prompt. My first version said "extract all insights" — way too noisy. Narrowing it to "only extract what you'd actually need in the next session" made a huge difference. This tuning is still ongoing.&lt;/p&gt;

&lt;h2&gt;
  
  
  Setup
&lt;/h2&gt;

&lt;p&gt;KIOKU has an interactive setup. Just enter this in Claude Code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Please read skills/setup-guide/SKILL.md and guide me through the KIOKU installation.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Claude Code itself walks you through each step, explaining what it does and adapting to your environment. Manual setup instructions are also in the README — only 5 required steps.&lt;/p&gt;

&lt;h2&gt;
  
  
  Roadmap
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Multi-LLM support&lt;/strong&gt;: Currently Claude Code (Max plan) only. Planning to make the LLM backend pluggable (OpenAI API, local models via Ollama, etc.)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Morning Briefing&lt;/strong&gt;: Auto-generated daily summary — yesterday's sessions, open decisions, new insights&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Project-aware context injection&lt;/strong&gt;: Filter injected wiki content by the current project (based on cwd)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Team Wiki&lt;/strong&gt;: Multi-person wiki sharing (each member's session-logs stay local; only wiki/ syncs via Git)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Wrapping Up
&lt;/h2&gt;

&lt;p&gt;Claude Code is a powerful tool, but the lack of cross-session memory is a significant gap. KIOKU fills that gap by automatically growing a knowledge base from your conversations and feeding it back into every new session.&lt;/p&gt;

&lt;p&gt;It's an implementation of Karpathy's LLM Wiki concept, specialized for Claude Code and fully automated. MIT licensed.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/megaphone-tokyo/kioku" rel="noopener noreferrer"&gt;https://github.com/megaphone-tokyo/kioku&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Feedback, issues, and PRs are very welcome. I'm especially interested in hearing about:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Is the wiki directory structure intuitive?&lt;/li&gt;
&lt;li&gt;How should the ingest selection criteria be tuned?&lt;/li&gt;
&lt;li&gt;Which LLM backends should be prioritized for multi-LLM support?&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;em&gt;Built by &lt;a href="https://x.com/megaphone_tokyo" rel="noopener noreferrer"&gt;@megaphone_tokyo&lt;/a&gt; — building things with code and AI. Freelance engineer, 10 years in. Tokyo, Japan.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>claudecode</category>
      <category>ai</category>
      <category>obsidian</category>
      <category>opensource</category>
    </item>
  </channel>
</rss>
