<?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: arsyadal</title>
    <description>The latest articles on DEV Community by arsyadal (@arsyadal).</description>
    <link>https://dev.to/arsyadal</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.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1409697%2Fed66a02a-b2dd-413e-a16b-fc5f37333014.png</url>
      <title>DEV Community: arsyadal</title>
      <link>https://dev.to/arsyadal</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/arsyadal"/>
    <language>en</language>
    <item>
      <title>How We Correlated LLM Tool Calls with Git Diff Hunks to Automate PR Narratives</title>
      <dc:creator>arsyadal</dc:creator>
      <pubDate>Wed, 05 Aug 2026 14:38:04 +0000</pubDate>
      <link>https://dev.to/arsyadal/how-we-correlated-llm-tool-calls-with-git-diff-hunks-to-automate-pr-narratives-289j</link>
      <guid>https://dev.to/arsyadal/how-we-correlated-llm-tool-calls-with-git-diff-hunks-to-automate-pr-narratives-289j</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;TL;DR&lt;/strong&gt;: AI coding agents like Claude Code and OpenClaw generate tons of code edits, but their commit history and PR descriptions are often messy or lack architectural rationale. We built &lt;a href="https://github.com/arsyadal/git-narrate" rel="noopener noreferrer"&gt;&lt;code&gt;git-narrate&lt;/code&gt;&lt;/a&gt; (&lt;code&gt;narrate&lt;/code&gt;) in pure Go to correlate agent transcripts directly with Git diffs in &amp;lt; 50ms, producing clean Conventional Commits and intent-aware PR descriptions automatically.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  The Problem: AI Code Agents are Fast, But Git History Suffers
&lt;/h2&gt;

&lt;p&gt;As developer workflows shift toward agentic coding tools—such as Claude Code, Cursor, Aider, and OpenClaw—the volume of code written per session has skyrocketed. Agents execute multiple file edits, create new modules, refactor functions, and run terminal commands within a single session.&lt;/p&gt;

&lt;p&gt;However, when it comes time to commit and create a Pull Request, developers face two major friction points:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Vague or Blob Commit Messages&lt;/strong&gt;: Commits like &lt;code&gt;"AI generated code"&lt;/code&gt; or &lt;code&gt;"updated files"&lt;/code&gt; obscure &lt;em&gt;why&lt;/em&gt; a particular architectural decision was made.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Time-Consuming PR Descriptions&lt;/strong&gt;: Reviewers need to understand the intent behind code edits. Manually summarizing 10+ modified files from memory or skimming agent logs takes significant effort.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;We asked: &lt;strong&gt;What if your CLI could parse the AI agent's internal transcript log, extract the developer's original prompt and reasoning, and automatically match every modified file hunk with its architectural intent?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Enter &lt;a href="https://github.com/arsyadal/git-narrate" rel="noopener noreferrer"&gt;&lt;code&gt;git-narrate&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  Arsitektur &amp;amp; How &lt;code&gt;git-narrate&lt;/code&gt; Works Under the Hood
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;git-narrate&lt;/code&gt; is written in Go 1.22+ with &lt;strong&gt;zero external CGO dependencies&lt;/strong&gt;. It operates in three main stages:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;┌───────────────────────────┐      ┌───────────────────────────┐
│ AI Agent Transcript Logs  │      │   Git Working Directory   │
│  (Claude Code / OpenClaw) │      │  (staged / unstaged diff) │
└─────────────┬─────────────┘      └─────────────┬─────────────┘
              │                                  │
              ▼                                  ▼
      ┌───────────────┐                  ┌───────────────┐
      │  pkg/parser   │                  │    pkg/git    │
      └───────┬───────┘                  └───────┬───────┘
              │                                  │
              └────────────────┬─────────────────┘
                               │
                               ▼
                    ┌─────────────────────┐
                    │    pkg/analyzer     │
                    │ (Correlation Engine)│
                    └──────────┬──────────┘
                               │
                               ▼
                    ┌─────────────────────┐
                    │    pkg/formatter    │
                    │  (Commit &amp;amp; PR Body) │
                    └─────────────────────┘
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Stage 1: Abstracting Transcripts (&lt;code&gt;pkg/parser&lt;/code&gt;)
&lt;/h3&gt;

&lt;p&gt;AI agent transcripts come in various formats:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Claude Code&lt;/strong&gt;: Multi-line &lt;code&gt;.jsonl&lt;/code&gt; or single &lt;code&gt;.json&lt;/code&gt; exports containing &lt;code&gt;USER_INPUT&lt;/code&gt;, &lt;code&gt;PLANNER_RESPONSE&lt;/code&gt;, and &lt;code&gt;tool_calls&lt;/code&gt; (&lt;code&gt;write_file&lt;/code&gt;, &lt;code&gt;FileEdit&lt;/code&gt;, &lt;code&gt;replace_file_content&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;OpenClaw&lt;/strong&gt;: Text log format featuring &lt;code&gt;[PROMPT]&lt;/code&gt;, &lt;code&gt;[TOOL]&lt;/code&gt;, and &lt;code&gt;[REASONING]&lt;/code&gt; line tags.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Our parser auto-detects the format and converts it into a unified internal Event AST:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;type&lt;/span&gt; &lt;span class="n"&gt;AgentEvent&lt;/span&gt; &lt;span class="k"&gt;struct&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;Timestamp&lt;/span&gt;   &lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Time&lt;/span&gt;      &lt;span class="s"&gt;`json:"timestamp"`&lt;/span&gt;
    &lt;span class="n"&gt;Kind&lt;/span&gt;        &lt;span class="n"&gt;AgentEventKind&lt;/span&gt; &lt;span class="s"&gt;`json:"kind"`&lt;/span&gt; &lt;span class="c"&gt;// user_prompt, tool_call, reasoning&lt;/span&gt;
    &lt;span class="n"&gt;Content&lt;/span&gt;     &lt;span class="kt"&gt;string&lt;/span&gt;         &lt;span class="s"&gt;`json:"content"`&lt;/span&gt;
    &lt;span class="n"&gt;ToolName&lt;/span&gt;    &lt;span class="kt"&gt;string&lt;/span&gt;         &lt;span class="s"&gt;`json:"tool_name,omitempty"`&lt;/span&gt;
    &lt;span class="n"&gt;TargetFiles&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt;       &lt;span class="s"&gt;`json:"target_files,omitempty"`&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Stage 2: Hunk-Level Diff Parsing (&lt;code&gt;pkg/git&lt;/code&gt;)
&lt;/h3&gt;

&lt;p&gt;Instead of depending on &lt;code&gt;libgit2&lt;/code&gt; or CGO bindings, &lt;code&gt;git-narrate&lt;/code&gt; wraps standard &lt;code&gt;os/exec&lt;/code&gt; commands to execute &lt;code&gt;git diff --no-color&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;It parses unified diff headers (&lt;code&gt;diff --git a/file b/file&lt;/code&gt;), calculates added/deleted line counts per file hunk, and determines file status (&lt;code&gt;M&lt;/code&gt; for modified, &lt;code&gt;A&lt;/code&gt; for added, &lt;code&gt;D&lt;/code&gt; for deleted, &lt;code&gt;R&lt;/code&gt; for renamed).&lt;/p&gt;

&lt;h3&gt;
  
  
  Stage 3: The Correlation Engine (&lt;code&gt;pkg/analyzer&lt;/code&gt;)
&lt;/h3&gt;

&lt;p&gt;The core innovation of &lt;code&gt;git-narrate&lt;/code&gt; is its &lt;strong&gt;Intent Matrix Correlation&lt;/strong&gt;:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Path Normalization&lt;/strong&gt;: Both agent target paths (e.g. &lt;code&gt;pkg/auth/auth.go&lt;/code&gt;) and Git diff paths are normalized.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Rationale Mapping&lt;/strong&gt;: For every modified file in the diff, the correlation engine searches back through preceding &lt;code&gt;AgentEvent&lt;/code&gt;s in the transcript to find the exact user prompt or agent reasoning that triggered that change.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Conventional Scope &amp;amp; Type Inference&lt;/strong&gt;:

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;_test.go&lt;/code&gt; or &lt;code&gt;test/&lt;/code&gt; → &lt;code&gt;type: test&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;.md&lt;/code&gt; or &lt;code&gt;docs/&lt;/code&gt; → &lt;code&gt;type: docs&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;File directory structure (&lt;code&gt;cmd/narrate&lt;/code&gt;, &lt;code&gt;pkg/auth&lt;/code&gt;) → &lt;code&gt;scope: narrate&lt;/code&gt;, &lt;code&gt;scope: auth&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Keyword heuristics (&lt;code&gt;fix&lt;/code&gt;, &lt;code&gt;refactor&lt;/code&gt;, &lt;code&gt;add&lt;/code&gt;) → &lt;code&gt;type: fix / refactor / feat&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  Benchmark &amp;amp; Performance
&lt;/h2&gt;

&lt;p&gt;Because &lt;code&gt;git-narrate&lt;/code&gt; relies strictly on standard Go data structures and light text scanning, execution speed is exceptionally fast:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Operation&lt;/th&gt;
&lt;th&gt;Average Execution Time&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;narrate ingest&lt;/code&gt; (1MB JSONL transcript)&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;~18ms&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;narrate rebase&lt;/code&gt; (Git diff correlation)&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;~24ms&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;narrate pr-body&lt;/code&gt; (Markdown rendering)&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;~12ms&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Total runtime is consistently &lt;strong&gt;under 50ms&lt;/strong&gt;, making it invisible in developer terminal workflows or pre-commit hooks.&lt;/p&gt;




&lt;h2&gt;
  
  
  How to Use &lt;code&gt;git-narrate&lt;/code&gt; Today
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Installation
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;go &lt;span class="nb"&gt;install &lt;/span&gt;github.com/arsyadal/git-narrate/cmd/narrate@latest
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;(Or download pre-compiled binaries for Linux, macOS, or Windows directly from &lt;a href="https://github.com/arsyadal/git-narrate/releases" rel="noopener noreferrer"&gt;GitHub Releases&lt;/a&gt;).&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Ingesting Agent Log &amp;amp; Rebasing Commits
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Step 1: Ingest agent transcript log&lt;/span&gt;
narrate ingest &lt;span class="nt"&gt;--log&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;session_transcript.jsonl

&lt;span class="c"&gt;# Step 2: Preview Conventional Commit story&lt;/span&gt;
narrate rebase &lt;span class="nt"&gt;--staged&lt;/span&gt;

&lt;span class="c"&gt;# Step 3: Automatically commit grouped changes&lt;/span&gt;
narrate rebase &lt;span class="nt"&gt;--staged&lt;/span&gt; &lt;span class="nt"&gt;--commit&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  3. Generating a Markdown PR Description
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;narrate pr-body &lt;span class="nt"&gt;--out&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;PR.md
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Outputs a clean, structured PR description ready for GitHub/GitLab:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;&lt;span class="gh"&gt;# Pull Request Description&lt;/span&gt;

&lt;span class="gu"&gt;## Summary&lt;/span&gt;
Implement user authentication and JWT validation middleware for API routing.

&lt;span class="gu"&gt;## Intent &amp;amp; Architectural Choices&lt;/span&gt;
&lt;span class="gu"&gt;### `feat(auth)`: add JWT authentication middleware&lt;/span&gt;
&lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="gs"&gt;**Intent**&lt;/span&gt;: Implement user authentication token verification in HTTP requests to secure API endpoints
&lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="gs"&gt;**Impacted Scope**&lt;/span&gt;: &lt;span class="sb"&gt;`auth`&lt;/span&gt;

&lt;span class="gu"&gt;## Files Modified&lt;/span&gt;
| File | Status | Added | Deleted | Rationale |
| --- | --- | --- | --- | --- |
| &lt;span class="sb"&gt;`pkg/auth/auth.go`&lt;/span&gt; | &lt;span class="sb"&gt;`A`&lt;/span&gt; | +35 | -0 | Implement user authentication token parser |

&lt;span class="gu"&gt;## Test Status&lt;/span&gt;
&lt;span class="p"&gt;-&lt;/span&gt; [x] Unit tests updated / added.
&lt;span class="p"&gt;-&lt;/span&gt; [x] Automated test suite executed cleanly.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Conclusion &amp;amp; Open Source Community
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;git-narrate&lt;/code&gt; brings clarity and architectural maintainability back to Git repositories in the age of AI agent coding. &lt;/p&gt;

&lt;p&gt;We would love your feedback, contributions, and ideas!&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;⭐️ &lt;strong&gt;Star the GitHub Repo&lt;/strong&gt;: &lt;a href="https://github.com/arsyadal/git-narrate" rel="noopener noreferrer"&gt;https://github.com/arsyadal/git-narrate&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;💬 &lt;strong&gt;Open an Issue / PR&lt;/strong&gt;: Feature requests for new AI agent log formats are welcome!&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>ai</category>
      <category>webdev</category>
      <category>programming</category>
      <category>productivity</category>
    </item>
  </channel>
</rss>
