<?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: kwo2002</title>
    <description>The latest articles on DEV Community by kwo2002 (@kwo2002).</description>
    <link>https://dev.to/kwo2002</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%2F3198562%2F1ec5e5f1-e774-4cc1-ba1e-3ea48118d20d.jpg</url>
      <title>DEV Community: kwo2002</title>
      <link>https://dev.to/kwo2002</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/kwo2002"/>
    <language>en</language>
    <item>
      <title>Capturing the "why" behind every Claude Code commit: building a memory layer with MCP and hooks</title>
      <dc:creator>kwo2002</dc:creator>
      <pubDate>Mon, 18 May 2026 06:55:55 +0000</pubDate>
      <link>https://dev.to/kwo2002/capturing-the-why-behind-every-claude-code-commit-building-a-memory-layer-with-mcp-and-hooks-4gal</link>
      <guid>https://dev.to/kwo2002/capturing-the-why-behind-every-claude-code-commit-building-a-memory-layer-with-mcp-and-hooks-4gal</guid>
      <description>&lt;p&gt;A week ago I opened a piece of code Claude Code had written for me. Looked at it and asked: &lt;em&gt;"Wait — why did I tell it to do it this way?"&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;I couldn't remember.&lt;/p&gt;

&lt;p&gt;I asked Claude again. The session was already closed. The new agent shrugged: &lt;em&gt;"Not sure why, but merging these seems fine."&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;I blamed my memory at first. Started taking notes in Notion. Quit within a week — when you commit 30+ times a day with AI, hand-curated notes don't scale.&lt;/p&gt;

&lt;p&gt;Eventually I had to admit it: this isn't a memory problem. It's a missing tool.&lt;/p&gt;

&lt;h2&gt;
  
  
  The blank git has never filled
&lt;/h2&gt;

&lt;p&gt;git has recorded &lt;em&gt;what&lt;/em&gt; changed almost perfectly for 20 years. But right next to it sits a blank that's never really been filled — &lt;strong&gt;why&lt;/strong&gt; you changed it, and &lt;strong&gt;which alternatives you rejected.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When humans wrote code, that blank was invisible. The author carried the answer. You could ask the engineer across the desk, or even six months later they'd remember most of it.&lt;/p&gt;

&lt;p&gt;The moment AI started writing code, the carrier vanished.&lt;/p&gt;

&lt;p&gt;Agents review dozens of alternatives in a single session. They pick one. They discard the rest. Then the session closes and that reasoning is gone forever — not buried in some archive, just gone. The context&lt;br&gt;
window evaporates with the session.&lt;/p&gt;

&lt;p&gt;If you've been using Claude Code, Cursor, or any AI coding agent daily, you've probably felt this. Code you "wrote" last week feels foreign. Six months from now? You'll just rewrite it.&lt;/p&gt;
&lt;h2&gt;
  
  
  What I built
&lt;/h2&gt;

&lt;p&gt;I started small. A hook that ran after every &lt;code&gt;git commit&lt;/code&gt;, asking Claude Code to dump three things to a file:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The original prompt I sent&lt;/li&gt;
&lt;li&gt;The alternatives Claude considered&lt;/li&gt;
&lt;li&gt;Why it picked the one it did&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Two months in, that single hook was saving me hours every week. Every &lt;em&gt;"wait, why did I do this?"&lt;/em&gt; moment turned into a 30-second lookup instead of a half-hour archaeology dig.&lt;/p&gt;

&lt;p&gt;Then I started wondering:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;What if a team could read this together?&lt;/li&gt;
&lt;li&gt;What if a past session's reasoning could auto-inject into the next session's context?&lt;/li&gt;
&lt;li&gt;What if a PM, who never opens the IDE, could see &lt;em&gt;why&lt;/em&gt; today's decisions were made — in plain prose?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That hook became a product. It's called &lt;strong&gt;AIFlare&lt;/strong&gt;.&lt;/p&gt;
&lt;h2&gt;
  
  
  How it works (the interesting part)
&lt;/h2&gt;

&lt;p&gt;AIFlare is three layers:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Claude Code Hooks&lt;/strong&gt; that fire on specific lifecycle events&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A local stdio MCP Server&lt;/strong&gt; that Claude Code spawns per session&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A backend&lt;/strong&gt; that stores entries and powers a shared web timeline&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;
  
  
  Layer 1: Hooks
&lt;/h3&gt;

&lt;p&gt;Claude Code's hook system lets you attach scripts to lifecycle events. AIFlare attaches to four:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;PostToolUse  (matcher: Bash + git commit)   →  capture context after commit
PostToolUse  (matcher: AskUserQuestion)     →  track when the agent asks the user
UserPromptSubmit                             →  accumulate prompts within a session
Stop / SessionEnd                            →  finalize session record
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The most important is the first. The moment you run &lt;code&gt;git commit&lt;/code&gt;, the hook fires a small Node.js script that:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Reads the latest commit hash via &lt;code&gt;git rev-parse HEAD&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Reads the cumulative prompts captured during this session&lt;/li&gt;
&lt;li&gt;Asks Claude Code (via its internal &lt;code&gt;context-capture&lt;/code&gt; Skill) to summarize intent, considered alternatives, and rejected paths&lt;/li&gt;
&lt;li&gt;POSTs the result to the AIFlare backend, authenticated via per-user API key&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;All of this runs &lt;strong&gt;in the background&lt;/strong&gt; — there's no manual step in the developer's flow. You commit, the entry appears in the timeline a few seconds later.&lt;/p&gt;

&lt;h3&gt;
  
  
  Layer 2: MCP Server
&lt;/h3&gt;

&lt;p&gt;The local MCP server is a Node.js process spawned per Claude Code session via &lt;code&gt;.mcp.json&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="nl"&gt;"mcpServers"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"aiflare"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"command"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"node"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"args"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;".claude/mcp-server/dist/index.js"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It exposes &lt;strong&gt;12 tools across 6 categories&lt;/strong&gt; — session summary, daily/weekly digest, session compare, prompt evaluation, and a &lt;code&gt;why&lt;/code&gt; lookup. Each category has both a &lt;em&gt;fetch&lt;/em&gt; tool and a &lt;em&gt;save&lt;/em&gt; tool. So when you run&lt;br&gt;
&lt;code&gt;/summarize&lt;/code&gt; inside Claude Code, the flow is:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;MCP &lt;code&gt;get_session_summary&lt;/code&gt; → returns structured aggregates from backend&lt;/li&gt;
&lt;li&gt;Claude Code reads that, drafts a human-readable Markdown summary&lt;/li&gt;
&lt;li&gt;MCP &lt;code&gt;save_session_report&lt;/code&gt; → persists the Markdown back to the backend&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This split matters: the LLM produces the &lt;em&gt;prose&lt;/em&gt;, while the backend produces the &lt;em&gt;facts&lt;/em&gt;. The two never confuse each other.&lt;/p&gt;
&lt;h3&gt;
  
  
  Layer 3: Backend
&lt;/h3&gt;

&lt;p&gt;The backend is Kotlin + Spring Boot 4 with PostgreSQL (entry storage), Redis (session cache), and JWT auth for the web console + HMAC-SHA256 API keys for the hook and MCP.&lt;/p&gt;

&lt;p&gt;Resource hierarchy is Org → Team → Project, scoped via a &lt;code&gt;UserScopedRole&lt;/code&gt; table and a &lt;code&gt;ScopedPermissionEvaluator&lt;/code&gt; wired into Spring's &lt;code&gt;@PreAuthorize&lt;/code&gt;. Soft delete via &lt;code&gt;@SQLRestriction&lt;/code&gt;, JPA auditing for&lt;br&gt;
&lt;code&gt;createdBy&lt;/code&gt; / &lt;code&gt;updatedBy&lt;/code&gt;, virtual threads on Java 21 for the OTel collector pipeline.&lt;/p&gt;

&lt;p&gt;The web console is Next.js 16 + React 19 + Tailwind 4 + Zustand. Server components for SEO-facing pages, client components for the dashboard.&lt;/p&gt;

&lt;p&gt;Nothing exotic in the stack. The interesting part is the data model and the capture loop, not the framework choice.&lt;/p&gt;
&lt;h2&gt;
  
  
  Context Inject: closing the loop
&lt;/h2&gt;

&lt;p&gt;Here's the feature that turned the tool from "useful notes" into something I rely on daily.&lt;/p&gt;

&lt;p&gt;When you finish a session with &lt;code&gt;/summarize&lt;/code&gt;, the Markdown report is stored to the backend with a &lt;code&gt;sessionId&lt;/code&gt;. Days or weeks later, in a fresh Claude Code session, you can run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;/context-inject &amp;lt;sessionId&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The MCP tool fetches that past session's report and injects it directly into the new session's context. The new agent now knows what the last session decided, why, and what was rejected — before you've even typed&lt;br&gt;
your first prompt.&lt;/p&gt;

&lt;p&gt;This breaks the &lt;em&gt;"every session starts from zero"&lt;/em&gt; problem. The decision history accumulates, and the agent gets smarter not from training, but from your team's actual record.&lt;/p&gt;

&lt;p&gt;Future ideas (not built yet):&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Auto-inject relevant past sessions based on the files you're editing&lt;/li&gt;
&lt;li&gt;Warn the agent before it suggests a previously-rejected approach&lt;/li&gt;
&lt;li&gt;Enriched &lt;code&gt;git blame&lt;/code&gt; that includes the original intent&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What it looks like
&lt;/h2&gt;

&lt;p&gt;(Cover image / inline screenshot would go here — timeline view, showing intent + alternatives + linked prompts in one card.)&lt;/p&gt;

&lt;p&gt;Each entry is a card with:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Intent&lt;/strong&gt; — what the agent was trying to do&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Changes summary&lt;/strong&gt; — auto-generated, more readable than raw diff&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Alternatives considered&lt;/strong&gt; — including the ones rejected and why&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Linked prompts&lt;/strong&gt; — the full user/AI conversation that led to this commit&lt;/li&gt;
&lt;li&gt;Files affected, tags, comments, favorites&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The timeline reads more like a project blog feed than a git log. That's intentional — non-engineers should be able to follow along.&lt;/p&gt;

&lt;h2&gt;
  
  
  Stack summary
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Layer&lt;/th&gt;
&lt;th&gt;Tech&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Backend&lt;/td&gt;
&lt;td&gt;Kotlin 2.2, Spring Boot 4.0, Java 21 (virtual threads), PostgreSQL 16, Redis 7&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Frontend&lt;/td&gt;
&lt;td&gt;Next.js 16 (App Router), React 19, Tailwind 4, Zustand&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Hooks&lt;/td&gt;
&lt;td&gt;Node.js (cross-platform: macOS / Linux / Windows)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;MCP Server&lt;/td&gt;
&lt;td&gt;Node.js + TypeScript, &lt;code&gt;@modelcontextprotocol/sdk&lt;/code&gt;, stdio transport&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Observability&lt;/td&gt;
&lt;td&gt;OpenTelemetry → OTel Collector → Prometheus + Loki&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Auth&lt;/td&gt;
&lt;td&gt;JWT (web), HMAC-SHA256 API keys (CLI), Google + GitHub OAuth&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Email&lt;/td&gt;
&lt;td&gt;Resend&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Installer is a single Node.js script that places hooks, skills, and the MCP server into &lt;code&gt;.claude/&lt;/code&gt; and a pre-push hook into &lt;code&gt;.git/hooks/&lt;/code&gt;. One curl command, cross-platform.&lt;/p&gt;

&lt;h2&gt;
  
  
  Open beta — free, no card
&lt;/h2&gt;

&lt;p&gt;I launched as open beta two days ago. Free, no card required. Korean / English / Chinese from day one.&lt;/p&gt;

&lt;p&gt;What I'd most love isn't praise. It's the brutally honest version:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Here's exactly why I wouldn't use this.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That's the single most useful thing I can hear right now. If you try it and bounce, please tell me what made you bounce. Bug reports, &lt;em&gt;"this is dumb because X,"&lt;/em&gt; &lt;em&gt;"I'd use this if Y"&lt;/em&gt; — all of it.&lt;/p&gt;

&lt;p&gt;You can try the web demo or install in one line at &lt;strong&gt;&lt;a href="https://aiflare.dev" rel="noopener noreferrer"&gt;https://aiflare.dev&lt;/a&gt;&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I'm learning so far
&lt;/h2&gt;

&lt;p&gt;A few things have already surprised me from early users:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Non-engineers care more than I expected.&lt;/strong&gt;&lt;br&gt;
I thought this was a tool for engineers. Two PMs and a designer asked to be added to the beta in the first 48 hours, saying they wanted to follow team decisions without bothering engineering. That's a use case I&lt;br&gt;
underweighted.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. The "rejected alternatives" piece is the wedge.&lt;/strong&gt;&lt;br&gt;
People think they want better commit summaries. What they actually want is to know what the agent &lt;em&gt;didn't&lt;/em&gt; do, and why. That's the unique value I almost missed when scoping the MVP.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. MCP + hooks together is more than either alone.&lt;/strong&gt;&lt;br&gt;
Hooks capture passively. MCP exposes actively. Either alone is half the story — passive capture without active retrieval is just a graveyard, and active tools without passive capture means manual data entry. The&lt;br&gt;
combo is what makes the loop work.&lt;/p&gt;

&lt;h2&gt;
  
  
  Thanks for reading
&lt;/h2&gt;

&lt;p&gt;If you've got a minute — try it at &lt;a href="https://aiflare.dev" rel="noopener noreferrer"&gt;https://aiflare.dev&lt;/a&gt;, poke around the timeline, and send me the harshest, most specific feedback you can.&lt;/p&gt;

&lt;p&gt;Or if you just have a thought from reading this, drop it in the comments. I'll read every one.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>claude</category>
      <category>devtools</category>
      <category>showdev</category>
    </item>
  </channel>
</rss>
