<?xml version="1.0" encoding="UTF-8"?>
<rss  xmlns:atom="http://www.w3.org/2005/Atom" 
      xmlns:media="http://search.yahoo.com/mrss/" 
      xmlns:content="http://purl.org/rss/1.0/modules/content/" 
      xmlns:dc="http://purl.org/dc/elements/1.1/" 
      version="2.0">
<channel>
<title>uma-chan&#39;s page</title>
<link>https://i9wa4.github.io/feed.html</link>
<atom:link href="https://i9wa4.github.io/feed.xml" rel="self" type="application/rss+xml"/>
<description>All of my thoughts.</description>
<image>
<url>https://i9wa4.github.io/assets/common/icon_hhkb3_large.jpg</url>
<title>uma-chan&#39;s page</title>
<link>https://i9wa4.github.io/feed.html</link>
</image>
<generator>quarto-1.9.37</generator>
<lastBuildDate>Mon, 18 May 2026 07:40:00 GMT</lastBuildDate>
<item>
  <title>Markdown を設定ファイルにして tmux 上の AIエージェント間リレーを管理する</title>
  <dc:creator>uma-chan </dc:creator>
  <link>https://i9wa4.github.io/zenn/2026-05-18-tmux-a2a-postman.html</link>
  <description><![CDATA[ 





<section id="zenn-リンク先" class="level2">
<h2 class="anchored" data-anchor-id="zenn-リンク先">Zenn リンク先</h2>
<p>この記事は Zenn で公開されています。</p>
<p><a href="https://zenn.dev/genda_jp/articles/2026-05-18-tmux-a2a-postman">Markdown を設定ファイルにして tmux 上の AIエージェント間リレーを管理する</a></p>


</section>

 ]]></description>
  <category>zenn</category>
  <category>tmux</category>
  <category>claudecode</category>
  <category>codex</category>
  <category>aiagent</category>
  <category>multiagent</category>
  <guid>https://i9wa4.github.io/zenn/2026-05-18-tmux-a2a-postman.html</guid>
  <pubDate>Mon, 18 May 2026 07:40:00 GMT</pubDate>
  <media:content url="https://i9wa4.github.io/assets/common/zenn-ogp.png" medium="image" type="image/png" height="76" width="144"/>
</item>
<item>
  <title>tmux-a2a-postman: A Markdown Mailbox for Terminal AI Agents</title>
  <dc:creator>uma-chan </dc:creator>
  <link>https://i9wa4.github.io/en/blog/2026-05-17-tmux-a2a-postman-markdown-mail-for-ai-agent-teams.html</link>
  <description><![CDATA[ 





<section id="the-missing-layer" class="level2">
<h2 class="anchored" data-anchor-id="the-missing-layer">1. The Missing Layer</h2>
<p>This article is for people who use AI coding agents and are starting to care about durable instructions, explicit handoffs, reviewable task state, or mixing more than one terminal agent or tool in the same workflow.</p>
<p>You might already use Codex CLI, Claude Code, or another agent runtime, including native subagents, team features, or task delegation where they are available. Keep using them when they solve the problem. tmux-a2a-postman is about a different surface: a small local mailbox for handoffs that should stay visible outside one long chat, one model runtime, or one vendor-specific feature.</p>
<p>The pain I am solving is role overload. A single lead agent can become planner, implementer, reviewer, coordinator, memory keeper, and status reporter at once. Native subagents help narrow the work, but durable handoffs still need a place to live when work crosses runtime boundaries, lasts longer than one context window, or needs evidence that another role can inspect later.</p>
<p>In my local setup, tmux and <code>vde-layout</code> give me the physical workspace: long-lived panes, repeatable layouts, and a user-facing <code>ui_pane</code> so the human does not need to become a tmux operator for every task. That workspace is useful, but it is not a coordination protocol.</p>
<p>The missing layer is the handoff surface:</p>
<ul>
<li>who may talk to whom</li>
<li>what request was delivered</li>
<li>which context entered the next agent’s window</li>
<li>whether the receiver claimed it</li>
<li>whether a reply is required</li>
<li>what evidence remains later</li>
</ul>
<p>tmux-a2a-postman is my small local answer to that gap.</p>
<p>Repository: <a href="https://github.com/i9wa4/tmux-a2a-postman" class="uri">https://github.com/i9wa4/tmux-a2a-postman</a></p>
</section>
<section id="the-core-task-route" class="level2">
<h2 class="anchored" data-anchor-id="the-core-task-route">2. The Core Task Route</h2>
<p>Postman runs as a resident daemon in a tmux pane:</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb1" style="background: #f1f3f5;"><pre class="sourceCode bash code-with-copy"><code class="sourceCode bash"><span id="cb1-1"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">tmux-a2a-postman</span> start</span></code></pre></div></div>
<p>A trimmed and anonymized view looks like this. The project names are synthetic, but the emoji/status-marker style follows the current daemon output:</p>
<pre class="text"><code>tmux-a2a-postman git-b2c8283   [up/down:move] [p:ping] [q:quit]

[sessions]
  ⚫ [0] shell
&gt; 🟡 [1] article-edit
  🟢 [2] docs-review
  🔷 [3] runtime-workbench

[nodes]
messenger     🟡  waiting
orchestrator  🔷  pending
worker        🟢  ready
guardian      🟢  ready
critic        🟢  ready
boss          🟢  ready</code></pre>
<p>The important part is not the dashboard itself. Once a task is handed off, postman keeps the route and reply obligation outside terminal scrollback: messenger to orchestrator to worker to reviewer to messenger can be a Markdown-defined path instead of a human remembering which pane should answer next. Agent Skills add local operating rules for each role when they materially help.</p>
<p>The compact heartbeat is deliberately dense:</p>
<pre class="text"><code>[0]⚫ [1]🟡:🟡🔷🟢🟢🟢🟢 [2]🟢:🟢🟢🟢🟢🟢🟢 [3]🔷:🔷🟢🟢🟢🟢🟢</code></pre>
<p>I use <code>get-status</code> for full inspection and <code>get-status-oneline</code> for a status-bar-sized heartbeat. This is the concrete value: I can see that mail is moving, a reply is still open, or a role is waiting without treating the agent panes as the source of truth.</p>
<p>The <a href="https://github.com/i9wa4/tmux-a2a-postman#quick-start">README quick start</a> is still the right place for installation and command details. The article-level point is smaller: postman turns terminal-agent handoffs into visible local state.</p>
</section>
<section id="what-it-is" class="level2">
<h2 class="anchored" data-anchor-id="what-it-is">3. What It Is</h2>
<p>tmux-a2a-postman is a local mailbox and coordination layer for terminal agents, implemented on top of tmux.</p>
<p>It does not create the model, write the code, isolate a container, or decide a workflow by itself. It delivers Markdown messages between role-labeled terminal panes, records unread and read mail, tracks reply-required obligations, and exposes status.</p>
<p>The value spine is simple: turn “I told that agent something” into “there is a Markdown mail item with a sender, receiver, inbox/read state, and an exact reply slot when one is required.”</p>
<table class="caption-top table">
<colgroup>
<col style="width: 47%">
<col style="width: 52%">
</colgroup>
<thead>
<tr class="header">
<th>Before postman</th>
<th>With postman</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td>Requests live in one chat or pane</td>
<td>Requests are delivered as Markdown mail</td>
</tr>
<tr class="even">
<td>Handoff context is whatever is nearby</td>
<td>Handoff context is chosen for this request</td>
</tr>
<tr class="odd">
<td>Replies are inferred from terminal text</td>
<td>Required replies close exact input requests</td>
</tr>
<tr class="even">
<td>Old constraints live in chat history</td>
<td>Current constraints travel with the handoff</td>
</tr>
<tr class="odd">
<td>Routing rules are team convention</td>
<td>Routing and role contracts are Markdown</td>
</tr>
</tbody>
</table>
<p>This is not internal agent memory. It does not make an agent remember everything. It makes pending work, delivered mail, unread/read state, reply obligations, and delivery evidence visible as local state.</p>
<p>For larger investigation notes, I use a separate Markdown artifact workflow such as <a href="../../en/blog/2026-03-22-mkmd-mktemp-wrapper-for-ai-agents.html"><code>mkmd</code></a>. The two fit well together, but they are not the same layer.</p>
</section>
<section id="postman.md-as-the-control-surface" class="level2">
<h2 class="anchored" data-anchor-id="postman.md-as-the-control-surface">4. postman.md as the Control Surface</h2>
<p>The center of the setup is <code>postman.md</code>.</p>
<p>It is a Markdown file that humans can review and agents can read. It can contain the team topology, role instructions, shared rules, and Agent Skills catalog references.</p>
<p>This is the part I usually want outside a native model feature. A runtime may provide its own subagents or task tools, but <code>postman.md</code> is a local Markdown contract I can review in Git and apply across terminal tools. Behavior changes by editing Markdown, not by writing framework code; that keeps orchestration readable, versionable, and easy for an AI agent to patch in a normal diff.</p>
<p>A compact synthetic <code>postman.md</code> can show the moving parts without exposing private workflow details:</p>
<div class="code-with-filename">
<div class="code-with-filename-file">
<pre><strong>postman.md</strong></pre>
</div>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb4" data-filename="postman.md" style="background: #f1f3f5;"><pre class="sourceCode markdown code-with-copy"><code class="sourceCode markdown"><span id="cb4-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">---</span></span>
<span id="cb4-2"><span class="an" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">skill_path:</span></span>
<span id="cb4-3"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">  - path: ~/.codex/skills</span></span>
<span id="cb4-4"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">    inject: ping</span></span>
<span id="cb4-5"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">    skills:</span></span>
<span id="cb4-6"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">      - postman-session-operator</span></span>
<span id="cb4-7"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">      - postman-send-message</span></span>
<span id="cb4-8"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">---</span></span>
<span id="cb4-9"></span>
<span id="cb4-10"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">## `edges`</span></span>
<span id="cb4-11"></span>
<span id="cb4-12"><span class="in" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">```mermaid</span></span>
<span id="cb4-13">graph LR</span>
<span id="cb4-14">    messenger --- orchestrator</span>
<span id="cb4-15">    orchestrator --- worker</span>
<span id="cb4-16">    orchestrator --- reviewer</span>
<span id="cb4-17">    class messenger ui_node</span>
<span id="cb4-18">    classDef ui_node fill:<span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#e0f2fe</span></span>
<span id="cb4-19"><span class="in" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">```</span></span>
<span id="cb4-20"></span>
<span id="cb4-21"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">## `common_template`</span></span>
<span id="cb4-22"></span>
<span id="cb4-23">Use postman mail for handoffs. Required work ends with DONE or BLOCKED and evidence.</span>
<span id="cb4-24"></span>
<span id="cb4-25"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">## `orchestrator`</span></span>
<span id="cb4-26"></span>
<span id="cb4-27"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">### `role`</span></span>
<span id="cb4-28"></span>
<span id="cb4-29">Coordinator. Delegate implementation to <span class="in" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">`worker`</span> and request review from <span class="in" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">`reviewer`</span>.</span>
<span id="cb4-30"></span>
<span id="cb4-31"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">## `worker`</span></span>
<span id="cb4-32"></span>
<span id="cb4-33"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">### `role`</span></span>
<span id="cb4-34"></span>
<span id="cb4-35">Implementation role. Reply with changed files, validation, and blockers.</span>
<span id="cb4-36"></span>
<span id="cb4-37"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">## `reviewer`</span></span>
<span id="cb4-38"></span>
<span id="cb4-39"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">### `role`</span></span>
<span id="cb4-40"></span>
<span id="cb4-41">Review role. Return evidence-backed APPROVED or NOT APPROVED.</span></code></pre></div></div>
</div>
<p>Rendered, the same <code>edges</code> section is intentionally small:</p>
<div class="cell" data-layout-align="default">
<div class="cell-output-display">
<div>
<p></p><figure class="figure"><p></p>
<div>
<pre class="mermaid mermaid-js">graph LR
    messenger["messenger"]
    orchestrator["orchestrator"]
    worker["worker"]
    reviewer["reviewer"]

    messenger --- orchestrator
    orchestrator --- worker
    orchestrator --- reviewer

    class messenger entry
    class orchestrator,worker,reviewer role
    classDef entry fill:#dbeafe,stroke:#2563eb,color:#0f172a
    classDef role fill:#f8fafc,stroke:#64748b,color:#0f172a
</pre>
</div>
<p></p></figure><p></p>
</div>
</div>
</div>
<p>The diagram is not decoration. The node names and <code>---</code> edges define which roles may talk to each other. With <code>inject: ping</code>, the <code>skill_path</code> block injects a compact Agent Skills catalog into recurring daemon PING role content, while the role sections keep the review loop and reply expectations local to Markdown. Postman only treats a small parsed subset as routing and Agent Skills catalog data; the rest stays useful as human-readable role context.</p>
<p>Each received mail item carries the relevant <code>postman.md</code> instructions with the request: role context, routing expectations, reply shape, and available Agent Skills when configured. That matters over longer tasks because the receiving agent can re-read its local contract instead of relying on nearby pane history.</p>
<p>A review loop can then stay in mail instead of terminal scrollback:</p>
<pre class="text"><code>messenger -&gt; orchestrator: tighten the article and validate it

orchestrator -&gt; worker: make the scoped edit

worker -&gt; orchestrator: DONE with changed files and checks

orchestrator -&gt; reviewer: verify before user-facing completion

reviewer -&gt; orchestrator: APPROVED or NOT APPROVED with evidence</code></pre>
<p>This block is not displayed by tmux-a2a-postman’s TUI. It is a compact example of Markdown mail handoff and reply shape.</p>
<p>That does not make the result correct by itself. It makes three kinds of forgetting harder: role drift, dropped reply-required loops, and forgotten local capabilities. <code>postman.md</code> carries role and routing expectations with the mail, reply-required keeps open loops visible, and the Agent Skills catalog gives the receiver compact names and descriptions for local capabilities it can choose when needed.</p>
<p>The full <code>SKILL.md</code> body stays out of the prompt until the task actually needs it. The catalog is a reminder to use known local behavior before improvising.</p>
</section>
<section id="the-mail-handoff-agents-can-operate" class="level2">
<h2 class="anchored" data-anchor-id="the-mail-handoff-agents-can-operate">5. The Mail Handoff Agents Can Operate</h2>
<p>The mail handoff is intentionally small: one role sends Markdown mail, the receiver claims it, reads the archived body, and answers required requests with <code>DONE</code> or <code>BLOCKED</code> plus evidence.</p>
<p>tmux-a2a-postman’s own Agent Skills make the handoff operational: sender roles learn the heredoc send path; receiver roles learn that archived mail must be read, required replies must close exact input requests, and blocked or delivery failures must be reported. <code>postman-config-auditor</code> covers topology and config checks when routes or role definitions need review.</p>
<p>This closes transport state, not truth. A <code>DONE</code> reply still needs evidence. A reviewer, orchestrator, or human can inspect changed files, test output, and the task artifact before accepting the result.</p>
</section>
<section id="why-tmux-native" class="level2">
<h2 class="anchored" data-anchor-id="why-tmux-native">6. Why tmux-Native</h2>
<p>Postman is intentionally tmux-native today. That is an implementation choice, not the reader identity.</p>
<p>It uses tmux-specific surfaces: session, window, and pane discovery; operator-controlled pane titles as role labels and routing keys; tmux input delivery; pane capture for bounded activity evidence; and tmux pane metadata.</p>
<p>Those are implementation facts, not universal claims about terminal tools. The portable ideas are shell-first operation, local filesystem mail, human-reviewable Markdown contracts, heterogeneous CLI agents side by side, and visible handoff state.</p>
<p>So the comparison I care about is category-level:</p>
<table class="caption-top table">
<colgroup>
<col style="width: 43%">
<col style="width: 56%">
</colgroup>
<thead>
<tr class="header">
<th>Category</th>
<th>What it usually solves</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td>Native agent features</td>
<td>In-runtime delegation, subagents, tool use</td>
</tr>
<tr class="even">
<td>Agent runtime</td>
<td>Thinking, editing, tool execution</td>
</tr>
<tr class="odd">
<td>Terminal multiplexer substrate</td>
<td>Long-lived panes, sessions, input surfaces</td>
</tr>
<tr class="even">
<td>Workspace layout harness</td>
<td>Recreate the physical workspace</td>
</tr>
<tr class="odd">
<td>Mailbox and coordination layer</td>
<td>Handoffs, unread state, replies, receipts</td>
</tr>
</tbody>
</table>
<p>Postman lives in the last row and currently runs on tmux.</p>
</section>
<section id="boundaries-and-composition" class="level2">
<h2 class="anchored" data-anchor-id="boundaries-and-composition">7. Boundaries and Composition</h2>
<p>tmux-a2a-postman is not an AI coding agent, a full multi-agent framework, a workflow engine, a sandbox, an MCP server, an A2A-compliant server, or a replacement for Claude Code, Codex CLI, tmux, or <code>vde-layout</code>.</p>
<p>The name uses <code>a2a</code> in the agent-to-agent handoff sense and borrows useful A2A-style vocabulary for messages, contexts, artifacts, and input-required states. It is not currently a standards-compliant A2A endpoint.</p>
<p>I use native subagents or team features for work inside one runtime, tmux for the workbench, <code>vde-layout</code> for repeatable pane creation, Agent Skills or local instructions for role behavior, <code>mkmd</code> for larger task artifacts, and postman for handoffs between terminal roles and tools.</p>
<p>Each layer can be replaced or improved without pretending one tool should own everything. The transport cares about pane titles, shell commands, and local mail files, not a specific model vendor or agent API. Claude Code, Codex CLI, Gemini CLI, OpenCode, or another terminal agent can sit behind the same role name as long as it can read mail, act, and reply.</p>
</section>
<section id="summary" class="level2">
<h2 class="anchored" data-anchor-id="summary">8. Summary</h2>
<p>Terminal agents can already think, edit, run commands, and sometimes delegate to native subagents or team features. Keep those capabilities.</p>
<p>The missing piece is the local handoff layer: who may talk to whom, what was delivered, what remains unread, who owes a reply, and what evidence remains when delivery or task completion needs inspection.</p>
<p>tmux-a2a-postman is a mailbox, not a brain. It is a receipt layer, not a proof of correctness. It is Markdown-forward, not attachment-based. It is tmux-native today, while the core idea is portable: local agents work better when handoffs are explicit, reviewable, and recoverable.</p>


<div class="social-share"><a href="https://twitter.com/share?url=https%3A%2F%2Fi9wa4.github.io%2Fen%2Fblog%2F2026-05-17-tmux-a2a-postman-markdown-mail-for-ai-agent-teams.html&amp;text=tmux-a2a-postman%3A%20A%20Markdown%20Mailbox%20for%20Terminal%20AI%20Agents%20%E2%80%93%20uma-chan%E2%80%99s%20page" target="_blank" class="twitter"><i class="bi bi-twitter-x"></i></a><a href="https://bsky.app/intent/compose?text=tmux-a2a-postman%3A%20A%20Markdown%20Mailbox%20for%20Terminal%20AI%20Agents%20%E2%80%93%20uma-chan%E2%80%99s%20page%20https%3A%2F%2Fi9wa4.github.io%2Fen%2Fblog%2F2026-05-17-tmux-a2a-postman-markdown-mail-for-ai-agent-teams.html" target="_blank" class="bsky"><i class="bi bi-bluesky"></i></a><a href="https://www.linkedin.com/shareArticle?url=https%3A%2F%2Fi9wa4.github.io%2Fen%2Fblog%2F2026-05-17-tmux-a2a-postman-markdown-mail-for-ai-agent-teams.html&amp;title=tmux-a2a-postman%3A%20A%20Markdown%20Mailbox%20for%20Terminal%20AI%20Agents%20%E2%80%93%20uma-chan%E2%80%99s%20page" target="_blank" class="linkedin"><i class="bi bi-linkedin"></i></a></div>
</section>

 ]]></description>
  <category>blog</category>
  <category>tech-ai</category>
  <guid>https://i9wa4.github.io/en/blog/2026-05-17-tmux-a2a-postman-markdown-mail-for-ai-agent-teams.html</guid>
  <pubDate>Sun, 17 May 2026 03:16:22 GMT</pubDate>
  <media:content url="https://i9wa4.github.io/assets/common/icon_hhkb3_large.jpg" medium="image" type="image/jpeg"/>
</item>
<item>
  <title>Build Repeatable tmux Workspaces for CLI Agents with vde-layout</title>
  <dc:creator>uma-chan </dc:creator>
  <link>https://i9wa4.github.io/en/blog/2026-05-17-repeatable-tmux-workspaces-for-ai-agents.html</link>
  <description><![CDATA[ 





<section id="the-problem" class="level2">
<h2 class="anchored" data-anchor-id="the-problem">1. The Problem</h2>
<p>Running one AI coding agent in a terminal is simple.</p>
<p>Running several of them for real work is a different shape of problem. I want an editor, a shell, one or more agent panes, maybe a reviewer pane, and a place to inspect Git state. I also want the same layout tomorrow, in another repository, without remembering which split command I used last time.</p>
<p>Manually doing this is boring:</p>
<ol type="1">
<li>Split a tmux pane.</li>
<li>Resize the pane.</li>
<li>Split it again.</li>
<li>Start Vim, Claude Code, Codex CLI, or another CLI agent.</li>
<li>Rename enough things that I can still tell what is happening.</li>
</ol>
<p>The more useful the setup becomes, the more annoying it is to recreate.</p>
<p>So I treat the terminal workspace as something that should be declared, versioned, and replayed. tmux is the workbench. <code>vde-layout</code> is the repeatable floor plan.</p>
<p>This is also why I still care about dotfiles. I want the behavior of my environment to live in text files that Git can track. I wrote more about that in <a href="../../en/blog/2026-01-08-why-i-still-grow-my-dotfiles.html">Why I Still Grow My Dotfiles in the Age of AI Coding Agents</a>.</p>
</section>
<section id="why-tmux" class="level2">
<h2 class="anchored" data-anchor-id="why-tmux">2. Why tmux</h2>
<p>For this workflow, tmux is useful because it gives long-lived terminal surfaces that can be controlled from the outside.</p>
<p>The important pieces are:</p>
<table class="caption-top table">
<thead>
<tr class="header">
<th>tmux concept</th>
<th>How I use it</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td>Session</td>
<td>One project or work context</td>
</tr>
<tr class="even">
<td>Window</td>
<td>One screen inside the project</td>
</tr>
<tr class="odd">
<td>Pane</td>
<td>One long-running shell or agent</td>
</tr>
<tr class="even">
<td>Pane title</td>
<td>A visible role label for the operator</td>
</tr>
</tbody>
</table>
<p>A pane title is not a permanent identity guarantee. It is an operator-controlled label that helps humans and scripts route attention. The stable part of the workflow comes from combining tmux’s process model with explicit configuration and checks, not from pretending that a title can never change.</p>
<p>tmux is not the only possible terminal substrate. Zellij, editor-integrated terminals, and AI-first editor environments all have strong workflows. My point here is narrower: tmux exposes a mature local model of sessions, windows, panes, pane titles, input commands, and pane capture. That makes it a practical substrate for shell-first agent work today.</p>
</section>
<section id="the-minimum-tmux-model" class="level2">
<h2 class="anchored" data-anchor-id="the-minimum-tmux-model">3. The Minimum tmux Model</h2>
<p>The mental model is close to a browser:</p>
<table class="caption-top table">
<colgroup>
<col style="width: 11%">
<col style="width: 33%">
<col style="width: 55%">
</colgroup>
<thead>
<tr class="header">
<th>Layer</th>
<th>Browser analogy</th>
<th>Agent workflow analogy</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td>Session</td>
<td>Browser window</td>
<td>Project workspace</td>
</tr>
<tr class="even">
<td>Window</td>
<td>Browser tab</td>
<td>A named screen inside that project</td>
</tr>
<tr class="odd">
<td>Pane</td>
<td>Split view inside tab</td>
<td>Editor, shell, or CLI agent process</td>
</tr>
</tbody>
</table>
<p>I keep one tmux session per project. Inside that session, I can have a main work window, a review window, or a monitoring window. Inside each window, each pane owns one long-lived process.</p>
<p>That sounds simple, but it matters for CLI agents. A pane can keep a conversation alive while I inspect another pane. A session can detach and survive terminal restarts. A window can group related roles without mixing every process into one crowded screen.</p>
<p>The goal is not to make tmux fancy. The goal is to give agents stable places to run.</p>
</section>
<section id="a-few-tmux-settings-that-matter" class="level2">
<h2 class="anchored" data-anchor-id="a-few-tmux-settings-that-matter">4. A Few tmux Settings That Matter</h2>
<p>I try to reduce prefix-heavy operations because multi-pane work requires frequent movement.</p>
<p>For window and session movement:</p>
<div class="code-with-filename">
<div class="code-with-filename-file">
<pre><strong>~/.config/tmux/tmux.conf</strong></pre>
</div>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb1" data-filename="~/.config/tmux/tmux.conf" style="background: #f1f3f5;"><pre class="sourceCode conf code-with-copy"><code class="sourceCode toml"><span id="cb1-1"><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">bind-key</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">-n</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">M-Left</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">previous-window</span></span>
<span id="cb1-2"><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">bind-key</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">-n</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">M-Right</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">next-window</span></span>
<span id="cb1-3"><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">bind-key</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">-n</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">M-Up</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">switch-client</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">-p</span></span>
<span id="cb1-4"><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">bind-key</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">-n</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">M-Down</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">switch-client</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">-n</span></span></code></pre></div></div>
</div>
<p>For pane movement:</p>
<div class="code-with-filename">
<div class="code-with-filename-file">
<pre><strong>~/.config/tmux/tmux.conf</strong></pre>
</div>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb2" data-filename="~/.config/tmux/tmux.conf" style="background: #f1f3f5;"><pre class="sourceCode conf code-with-copy"><code class="sourceCode toml"><span id="cb2-1"><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">bind-key</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">-n</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">S-Left</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">select-pane</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">-L</span></span>
<span id="cb2-2"><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">bind-key</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">-n</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">S-Right</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">select-pane</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">-R</span></span>
<span id="cb2-3"><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">bind-key</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">-n</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">S-Up</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">select-pane</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">-U</span></span>
<span id="cb2-4"><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">bind-key</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">-n</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">S-Down</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">select-pane</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">-D</span></span></code></pre></div></div>
</div>
<p>On macOS, <code>M-</code> is usually Option. On Linux, it is usually Alt.</p>
<p>I also inherit the current directory when opening new panes or windows:</p>
<div class="code-with-filename">
<div class="code-with-filename-file">
<pre><strong>~/.config/tmux/tmux.conf</strong></pre>
</div>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb3" data-filename="~/.config/tmux/tmux.conf" style="background: #f1f3f5;"><pre class="sourceCode conf code-with-copy"><code class="sourceCode toml"><span id="cb3-1"><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">bind-key</span> <span class="er" style="color: #AD0000;
background-color: null;
font-style: inherit;">%</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">split-window</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">-h</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">-c</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">"#{pane_current_path}"</span></span>
<span id="cb3-2"><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">bind-key</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">'"'</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">split-window</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">-v</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">-c</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">"#{pane_current_path}"</span></span>
<span id="cb3-3"><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">bind-key</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">c</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">new-window</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">-c</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">"#{pane_current_path}"</span></span></code></pre></div></div>
</div>
<p>And I use popup windows for quick checks:</p>
<div class="code-with-filename">
<div class="code-with-filename-file">
<pre><strong>~/.config/tmux/tmux.conf</strong></pre>
</div>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb4" data-filename="~/.config/tmux/tmux.conf" style="background: #f1f3f5;"><pre class="sourceCode conf code-with-copy"><code class="sourceCode toml"><span id="cb4-1"><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">bind-key</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">u</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">display-popup</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">-d</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">'#{pane_current_path}'</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">-w</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">90</span><span class="er" style="color: #AD0000;
background-color: null;
font-style: inherit;">%</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">-h</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">90</span><span class="er" style="color: #AD0000;
background-color: null;
font-style: inherit;">%</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">-E</span></span>
<span id="cb4-2"><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">bind-key</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">g</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">display-popup</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">-d</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">'#{pane_current_path}'</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">-w</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">90</span><span class="er" style="color: #AD0000;
background-color: null;
font-style: inherit;">%</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">-h</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">90</span><span class="er" style="color: #AD0000;
background-color: null;
font-style: inherit;">%</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">-E</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">'lazygit'</span></span></code></pre></div></div>
</div>
<p>The popup is useful when an agent is working and I want to inspect Git state without disturbing the main pane layout.</p>
<p>These settings are not the center of the workflow. They just make the workbench pleasant enough to use all day.</p>
</section>
<section id="vde-layout-is-the-floor-plan" class="level2">
<h2 class="anchored" data-anchor-id="vde-layout-is-the-floor-plan">5. vde-layout Is the Floor Plan</h2>
<p><code>vde-layout</code> is a tmux layout tool by yuki-yano. You define panes and windows in YAML, then run one command to materialize them.</p>
<p>Repository: <a href="https://github.com/yuki-yano/vde-layout" class="uri">https://github.com/yuki-yano/vde-layout</a></p>
<p>This is the turning point. Instead of remembering tmux split commands, I define the workspace once:</p>
<div class="code-with-filename">
<div class="code-with-filename-file">
<pre><strong>~/.config/vde/layout.yml</strong></pre>
</div>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb5" data-filename="~/.config/vde/layout.yml" style="background: #f1f3f5;"><pre class="sourceCode yaml code-with-copy"><code class="sourceCode yaml"><span id="cb5-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">presets</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">:</span></span>
<span id="cb5-2"><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">  </span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">main</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">:</span></span>
<span id="cb5-3"><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">    </span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">name</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">:</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;"> main</span></span>
<span id="cb5-4"><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">    </span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">description</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">:</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;"> editor plus one worker</span></span>
<span id="cb5-5"><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">    </span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">windowMode</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">:</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;"> current-window</span></span>
<span id="cb5-6"><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">    </span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">layout</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">:</span></span>
<span id="cb5-7"><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">      </span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">type</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">:</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;"> horizontal</span></span>
<span id="cb5-8"><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">      </span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ratio</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">:</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;"> </span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">[</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">,</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;"> </span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">]</span></span>
<span id="cb5-9"><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">      </span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">panes</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">:</span></span>
<span id="cb5-10"><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">        </span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">-</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;"> </span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">name</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">:</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;"> editor</span></span>
<span id="cb5-11"><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">          </span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">command</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">:</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;"> vim</span></span>
<span id="cb5-12"><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">          </span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">focus</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">:</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;"> </span><span class="ch" style="color: #20794D;
background-color: null;
font-style: inherit;">true</span></span>
<span id="cb5-13"><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">        </span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">-</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;"> </span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">name</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">:</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;"> worker</span></span>
<span id="cb5-14"><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">          </span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">command</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">:</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;"> claude</span></span></code></pre></div></div>
</div>
<p>Then I run:</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb6" style="background: #f1f3f5;"><pre class="sourceCode bash code-with-copy"><code class="sourceCode bash"><span id="cb6-1"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">vde-layout</span> main</span></code></pre></div></div>
<p>That creates two panes: an editor and a worker agent.</p>
<p>The exact command is replaceable. Use <code>codex</code>, <code>gemini</code>, <code>opencode</code>, a plain shell, or any other long-running CLI process. The important part is that the physical workspace shape is now declared in a file.</p>
</section>
<section id="scaling-beyond-two-panes" class="level2">
<h2 class="anchored" data-anchor-id="scaling-beyond-two-panes">6. Scaling Beyond Two Panes</h2>
<p>Two panes are enough to show the idea, but the same model scales to a small local agent team.</p>
<p>For example:</p>
<div class="code-with-filename">
<div class="code-with-filename-file">
<pre><strong>~/.config/vde/layout.yml</strong></pre>
</div>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb7" data-filename="~/.config/vde/layout.yml" style="background: #f1f3f5;"><pre class="sourceCode yaml code-with-copy"><code class="sourceCode yaml"><span id="cb7-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">presets</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">:</span></span>
<span id="cb7-2"><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">  </span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">concierge</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">:</span></span>
<span id="cb7-3"><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">    </span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">name</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">:</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;"> concierge</span></span>
<span id="cb7-4"><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">    </span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">description</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">:</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;"> editor and user-facing shell</span></span>
<span id="cb7-5"><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">    </span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">windowMode</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">:</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;"> current-window</span></span>
<span id="cb7-6"><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">    </span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">layout</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">:</span></span>
<span id="cb7-7"><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">      </span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">type</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">:</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;"> horizontal</span></span>
<span id="cb7-8"><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">      </span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ratio</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">:</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;"> </span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">[</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">,</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;"> </span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">]</span></span>
<span id="cb7-9"><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">      </span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">panes</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">:</span></span>
<span id="cb7-10"><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">        </span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">-</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;"> </span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">name</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">:</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;"> editor</span></span>
<span id="cb7-11"><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">          </span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">command</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">:</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;"> vim</span></span>
<span id="cb7-12"><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">          </span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">focus</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">:</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;"> </span><span class="ch" style="color: #20794D;
background-color: null;
font-style: inherit;">true</span></span>
<span id="cb7-13"><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">        </span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">-</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;"> </span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">name</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">:</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;"> messenger</span></span>
<span id="cb7-14"><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">          </span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">command</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">:</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;"> codex</span></span>
<span id="cb7-15"></span>
<span id="cb7-16"><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">  </span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">builders</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">:</span></span>
<span id="cb7-17"><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">    </span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">name</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">:</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;"> builders</span></span>
<span id="cb7-18"><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">    </span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">description</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">:</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;"> implementation agents</span></span>
<span id="cb7-19"><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">    </span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">windowMode</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">:</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;"> new-window</span></span>
<span id="cb7-20"><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">    </span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">layout</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">:</span></span>
<span id="cb7-21"><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">      </span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">type</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">:</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;"> horizontal</span></span>
<span id="cb7-22"><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">      </span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ratio</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">:</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;"> </span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">[</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">,</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;"> </span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">]</span></span>
<span id="cb7-23"><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">      </span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">panes</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">:</span></span>
<span id="cb7-24"><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">        </span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">-</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;"> </span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">name</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">:</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;"> worker</span></span>
<span id="cb7-25"><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">          </span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">command</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">:</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;"> codex</span></span>
<span id="cb7-26"><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">        </span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">-</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;"> </span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">name</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">:</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;"> worker-alt</span></span>
<span id="cb7-27"><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">          </span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">command</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">:</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;"> claude</span></span>
<span id="cb7-28"></span>
<span id="cb7-29"><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">  </span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">review</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">:</span></span>
<span id="cb7-30"><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">    </span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">name</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">:</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;"> review</span></span>
<span id="cb7-31"><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">    </span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">description</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">:</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;"> review and final decision</span></span>
<span id="cb7-32"><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">    </span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">windowMode</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">:</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;"> new-window</span></span>
<span id="cb7-33"><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">    </span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">layout</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">:</span></span>
<span id="cb7-34"><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">      </span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">type</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">:</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;"> horizontal</span></span>
<span id="cb7-35"><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">      </span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ratio</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">:</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;"> </span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">[</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">,</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;"> </span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">]</span></span>
<span id="cb7-36"><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">      </span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">panes</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">:</span></span>
<span id="cb7-37"><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">        </span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">-</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;"> </span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">name</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">:</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;"> reviewer</span></span>
<span id="cb7-38"><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">          </span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">command</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">:</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;"> claude</span></span>
<span id="cb7-39"><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">        </span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">-</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;"> </span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">name</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">:</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;"> shell</span></span>
<span id="cb7-40"><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">          </span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">command</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">:</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;"> bash</span></span></code></pre></div></div>
</div>
<p>Then:</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb8" style="background: #f1f3f5;"><pre class="sourceCode bash code-with-copy"><code class="sourceCode bash"><span id="cb8-1"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">vde-layout</span> concierge</span>
<span id="cb8-2"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">vde-layout</span> builders</span>
<span id="cb8-3"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">vde-layout</span> review</span></code></pre></div></div>
<p>Only the first preset uses <code>current-window</code>. The later presets use <code>new-window</code>, so one command sequence can build a multi-window workspace.</p>
<p>The names in this YAML are role labels for the human operator. They make the workspace legible. They also become useful later when a coordination layer needs to address a pane by role.</p>
</section>
<section id="short-commands-help" class="level2">
<h2 class="anchored" data-anchor-id="short-commands-help">7. Short Commands Help</h2>
<p>I do not want to type three long <code>vde-layout</code> commands every time.</p>
<p>I use shell snippets for that. With <code>zeno.zsh</code>, a short keyword can expand into the full command sequence.</p>
<p>Repository: <a href="https://github.com/yuki-yano/zeno.zsh" class="uri">https://github.com/yuki-yano/zeno.zsh</a></p>
<p>For example:</p>
<div class="code-with-filename">
<div class="code-with-filename-file">
<pre><strong>~/.config/zeno/config.yaml</strong></pre>
</div>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb9" data-filename="~/.config/zeno/config.yaml" style="background: #f1f3f5;"><pre class="sourceCode yaml code-with-copy"><code class="sourceCode yaml"><span id="cb9-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">snippets</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">:</span></span>
<span id="cb9-2"><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">  </span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">-</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;"> </span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">name</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">:</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;"> (vde-layout) agent workspace</span></span>
<span id="cb9-3"><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">    </span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">keyword</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">:</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;"> va</span></span>
<span id="cb9-4"><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">    </span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">snippet</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">:</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;"> vde-layout concierge &amp;&amp; vde-layout builders &amp;&amp; vde-layout review</span></span></code></pre></div></div>
</div>
<p>Now <code>va</code> can expand into the complete layout command.</p>
<p>This is optional. A shell alias, an abbreviation, a Make target, or a small script would also work. The principle is the same: the workspace is defined in text and recreated with a short command.</p>
</section>
<section id="session-names-matter" class="level2">
<h2 class="anchored" data-anchor-id="session-names-matter">8. Session Names Matter</h2>
<p>When multiple projects are open, tmux session names become part of the operator interface.</p>
<p>I like repository-based session names. If I move into <code>my-project</code>, the tmux session should be named <code>my-project</code>. If the repository name contains dots, I usually replace them with dashes so it is easier to target from shell commands.</p>
<p>The managed version I would point readers to is <code>zeno.zsh</code>’s repository jump hook. If you use <code>zeno-ghq-cd</code> to choose a repository, register a post-hook that derives the tmux session name from the selected path:</p>
<div class="code-with-filename">
<div class="code-with-filename-file">
<pre><strong>~/.zshrc</strong></pre>
</div>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb10" data-filename="~/.zshrc" style="background: #f1f3f5;"><pre class="sourceCode zsh code-with-copy"><code class="sourceCode zsh"><span id="cb10-1"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">zeno-ghq-cd-post-hook-impl</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">()</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">{</span></span>
<span id="cb10-2">  <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">local</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">dir</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$ZENO_GHQ_CD_DIR</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span></span>
<span id="cb10-3">  <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">[[</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">-z</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$TMUX</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">||</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">-z</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$dir</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">]]</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">&amp;&amp;</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">return</span></span>
<span id="cb10-4"></span>
<span id="cb10-5">  <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">local</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">repository</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">${dir</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">t}</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span></span>
<span id="cb10-6">  <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">local</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">session</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">${repository</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">//</span><span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">.</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">-</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">}</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span></span>
<span id="cb10-7">  <span class="ex" style="color: null;
background-color: null;
font-style: inherit;">tmux</span> rename-session <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$session</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span></span>
<span id="cb10-8"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">}</span></span>
<span id="cb10-9"></span>
<span id="cb10-10"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">zle</span> <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">-N</span> zeno-ghq-cd-post-hook zeno-ghq-cd-post-hook-impl</span></code></pre></div></div>
</div>
<p>With that shape, repository selection is the managed entry point. <code>my.project</code> becomes <code>my-project</code>, and any <code>vde-layout</code> preset you run afterward lands in a tmux session whose project identity is already visible.</p>
<p>This is not required for <code>vde-layout</code>, but it helps when several agent workspaces are open at once. A session name tells me which project I am looking at before I even inspect the panes, and scripts can use the same label when targeting a workspace.</p>
</section>
<section id="what-this-layer-solves" class="level2">
<h2 class="anchored" data-anchor-id="what-this-layer-solves">9. What This Layer Solves</h2>
<p>After tmux and <code>vde-layout</code>, I get:</p>
<table class="caption-top table">
<thead>
<tr class="header">
<th>Need</th>
<th>Layer that handles it</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td>Long-lived terminal processes</td>
<td>tmux</td>
</tr>
<tr class="even">
<td>Multiple visible agents</td>
<td>tmux panes</td>
</tr>
<tr class="odd">
<td>Project-level grouping</td>
<td>tmux sessions</td>
</tr>
<tr class="even">
<td>Repeatable pane layout</td>
<td><code>vde-layout</code></td>
</tr>
<tr class="odd">
<td>Fast startup command</td>
<td>shell snippet</td>
</tr>
<tr class="even">
<td>Durable environment config</td>
<td>dotfiles</td>
</tr>
</tbody>
</table>
<p>This is already enough to improve daily work. I can restart a project workspace quickly. I can keep several agents visible. I can swap one agent runtime without redesigning the whole setup.</p>
<p>It also makes experimentation cheaper. If a layout is bad, I edit YAML. If an agent command changes, I edit one command string. If a role should move to another window, I change the floor plan.</p>
</section>
<section id="what-this-layer-does-not-solve" class="level2">
<h2 class="anchored" data-anchor-id="what-this-layer-does-not-solve">10. What This Layer Does Not Solve</h2>
<p>tmux and <code>vde-layout</code> create places for agents to run. They do not define handoffs.</p>
<p>After the workspace exists, new questions appear:</p>
<ul>
<li>Which pane is allowed to send work to which pane?</li>
<li>Did the receiver read the request?</li>
<li>Is someone waiting for a required reply?</li>
<li>Which reply closes which request?</li>
<li>Where is the durable evidence for a handoff?</li>
<li>What should happen when delivery fails?</li>
</ul>
<p>You can answer some of this with conventions and direct <code>tmux send-keys</code> calls, but the state is easy to lose. The terminal screen shows activity, not a durable delivery record.</p>
<p>That is the boundary I care about:</p>
<table class="caption-top table">
<colgroup>
<col style="width: 27%">
<col style="width: 72%">
</colgroup>
<thead>
<tr class="header">
<th>Layer</th>
<th>Responsibility</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td>tmux</td>
<td>Workbench: sessions, windows, panes, processes</td>
</tr>
<tr class="even">
<td><code>vde-layout</code></td>
<td>Floor plan: repeatable pane and window creation</td>
</tr>
<tr class="odd">
<td>Shell snippets</td>
<td>Launcher: short commands for common layouts</td>
</tr>
<tr class="even">
<td>Coordination layer</td>
<td>Handoffs: messages, replies, routing, receipts</td>
</tr>
</tbody>
</table>
<p>This article is about the first three rows.</p>
</section>
<section id="the-next-layer" class="level2">
<h2 class="anchored" data-anchor-id="the-next-layer">11. The Next Layer</h2>
<p>At this point tmux gives me stable places for agents to run, and <code>vde-layout</code> gives me a repeatable way to create those places.</p>
<p>The remaining problem is handoffs.</p>
<p>The next article is about the small mailbox layer I built on top of this setup: <a href="../../en/blog/2026-05-17-tmux-a2a-postman-markdown-mail-for-ai-agent-teams.html"><code>tmux-a2a-postman</code></a>.</p>
<p>It does not replace tmux or <code>vde-layout</code>. It adds messages, reply obligations, readable routing rules, and archived delivery evidence between panes.</p>
<p>That separation is the important idea: first make the physical workspace repeatable, then make the coordination inside it explicit.</p>


<div class="social-share"><a href="https://twitter.com/share?url=https%3A%2F%2Fi9wa4.github.io%2Fen%2Fblog%2F2026-05-17-repeatable-tmux-workspaces-for-ai-agents.html&amp;text=Build%20Repeatable%20tmux%20Workspaces%20for%20CLI%20Agents%20with%20vde-layout%20%E2%80%93%20uma-chan%E2%80%99s%20page" target="_blank" class="twitter"><i class="bi bi-twitter-x"></i></a><a href="https://bsky.app/intent/compose?text=Build%20Repeatable%20tmux%20Workspaces%20for%20CLI%20Agents%20with%20vde-layout%20%E2%80%93%20uma-chan%E2%80%99s%20page%20https%3A%2F%2Fi9wa4.github.io%2Fen%2Fblog%2F2026-05-17-repeatable-tmux-workspaces-for-ai-agents.html" target="_blank" class="bsky"><i class="bi bi-bluesky"></i></a><a href="https://www.linkedin.com/shareArticle?url=https%3A%2F%2Fi9wa4.github.io%2Fen%2Fblog%2F2026-05-17-repeatable-tmux-workspaces-for-ai-agents.html&amp;title=Build%20Repeatable%20tmux%20Workspaces%20for%20CLI%20Agents%20with%20vde-layout%20%E2%80%93%20uma-chan%E2%80%99s%20page" target="_blank" class="linkedin"><i class="bi bi-linkedin"></i></a></div>
</section>

 ]]></description>
  <category>blog</category>
  <category>tech-ai</category>
  <guid>https://i9wa4.github.io/en/blog/2026-05-17-repeatable-tmux-workspaces-for-ai-agents.html</guid>
  <pubDate>Sun, 17 May 2026 03:16:13 GMT</pubDate>
  <media:content url="https://i9wa4.github.io/assets/common/icon_hhkb3_large.jpg" medium="image" type="image/jpeg"/>
</item>
<item>
  <title>Generate lazygit Commit Messages with codex exec</title>
  <dc:creator>uma-chan </dc:creator>
  <link>https://i9wa4.github.io/en/blog/2026-05-15-lazygit-commit-messages-with-codex-exec.html</link>
  <description><![CDATA[ 





<section id="introduction" class="level2">
<h2 class="anchored" data-anchor-id="introduction">1. Introduction</h2>
<p>I previously wrote about calling Claude Code from a lazygit custom command with <code>claude -p</code> to generate a commit message from the staged diff.</p>
<p><a href="https://i9wa4.github.io/blog/2026-03-14-lazygit-commit-message.html">Previous article</a></p>
<p>This version replaces that helper with Codex CLI’s <code>codex exec</code> and changes the surrounding flow so commit-message generation runs alongside pre-commit hooks.</p>
<p>There is also a practical background reason. <a href="https://support.claude.com/en/articles/15036540-use-the-claude-agent-sdk-with-your-claude-plan">Anthropic’s support article</a> says that starting June 15, 2026, eligible Claude plans can claim monthly Agent SDK credits, and that Claude Code’s non-interactive <code>claude -p</code> usage is included in that credit pool. I read that as a reason to reduce my dependency on <code>claude -p</code> for small helper scripts.</p>
<p>That credit wording matters. This is not a claim that <code>claude -p</code> disappeared, and it is not a claim that Codex has some permanent special status. It is just the context for moving this particular helper to the tool I am using most often right now.</p>
</section>
<section id="target-behavior" class="level2">
<h2 class="anchored" data-anchor-id="target-behavior">2. Target Behavior</h2>
<p>In lazygit’s <code>files</code> panel, I want <code>Ctrl+G</code> to:</p>
<ol type="1">
<li>Read the staged diff</li>
<li>Ask AI for a one-line Conventional Commits message</li>
<li>Start the normal <code>git commit</code> flow</li>
<li>Run pre-commit hooks while the message is being generated</li>
<li>Open Vim with the generated draft inserted at the top</li>
</ol>
<p>The final commit still goes through the normal editor step. I can edit the message, replace it, or abort.</p>
</section>
<section id="lazygit-configuration" class="level2">
<h2 class="anchored" data-anchor-id="lazygit-configuration">3. lazygit Configuration</h2>
<p>I keep the lazygit custom command short and move the real logic into a shell script.</p>
<div class="code-with-filename">
<div class="code-with-filename-file">
<pre><strong>~/.config/lazygit/config.yml</strong></pre>
</div>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb1" data-filename="~/.config/lazygit/config.yml" style="background: #f1f3f5;"><pre class="sourceCode yaml code-with-copy"><code class="sourceCode yaml"><span id="cb1-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">customCommands</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">:</span></span>
<span id="cb1-2"><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">  </span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">-</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;"> </span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">key</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">:</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;"> &lt;c-g&gt;</span></span>
<span id="cb1-3"><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">    </span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">context</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">:</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;"> files</span></span>
<span id="cb1-4"><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">    </span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">output</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">:</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;"> terminal</span></span>
<span id="cb1-5"><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">    </span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">command</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">:</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;"> bash ~/.config/lazygit/lazygit-ai-commit.sh</span></span></code></pre></div></div>
</div>
<p><code>Ctrl+G</code> is registered for the <code>files</code> panel. <code>output: terminal</code> lets <code>git commit</code> and Vim run in the terminal instead of inside a small lazygit prompt.</p>
</section>
<section id="shell-script" class="level2">
<h2 class="anchored" data-anchor-id="shell-script">4. Shell Script</h2>
<p>Here is the full <code>~/.config/lazygit/lazygit-ai-commit.sh</code> script.</p>
<p>I checked this with Codex CLI v0.130.0.</p>
<div class="callout callout-style-simple callout-note callout-titled">
<div class="callout-header d-flex align-content-center collapsed" data-bs-toggle="collapse" data-bs-target=".callout-1-contents" aria-controls="callout-1" aria-expanded="false" aria-label="Toggle callout">
<div class="callout-icon-container">
<i class="callout-icon"></i>
</div>
<div class="callout-title-container flex-fill">
<span class="screen-reader-only">Note</span>4.1. <code>~/.config/lazygit/lazygit-ai-commit.sh</code>
</div>
<div class="callout-btn-toggle d-inline-block border-0 py-1 ps-1 pe-0 float-end"><i class="callout-toggle"></i></div>
</div>
<div id="callout-1" class="callout-1-contents callout-collapse collapse">
<div class="callout-body-container callout-body">
<div class="code-with-filename">
<div class="code-with-filename-file">
<pre><strong>~/.config/lazygit/lazygit-ai-commit.sh</strong></pre>
</div>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb2" data-filename="~/.config/lazygit/lazygit-ai-commit.sh" style="background: #f1f3f5;"><pre class="sourceCode bash code-with-copy"><code class="sourceCode bash"><span id="cb2-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#!/usr/bin/env bash</span></span>
<span id="cb2-2"></span>
<span id="cb2-3"><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">editor</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$(</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mktemp</span> /tmp/lazygit-ai-commit-editor.XXXXXX<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">)</span></span>
<span id="cb2-4"><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">staged_diff</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$(</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mktemp</span> /tmp/lazygit-ai-commit-staged-diff.XXXXXX<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">)</span></span>
<span id="cb2-5"><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">ai_message</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$(</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mktemp</span> /tmp/lazygit-ai-commit-ai-message.XXXXXX<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">)</span></span>
<span id="cb2-6"><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">ai_status</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$(</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mktemp</span> /tmp/lazygit-ai-commit-ai-status.XXXXXX<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">)</span></span>
<span id="cb2-7"><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">ai_stderr</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$(</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mktemp</span> /tmp/lazygit-ai-commit-ai-stderr.XXXXXX<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">)</span></span>
<span id="cb2-8"><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">ai_pid</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span></span>
<span id="cb2-9"></span>
<span id="cb2-10"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cleanup()</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">{</span></span>
<span id="cb2-11">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">[</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">-n</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$ai_pid</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">]</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">&amp;&amp;</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">kill</span> <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">-0</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$ai_pid</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span>/dev/null <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;&amp;</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">;</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">then</span></span>
<span id="cb2-12">    <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">kill</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$ai_pid</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span>/dev/null <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;&amp;</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">||</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">true</span></span>
<span id="cb2-13">    <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">wait</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$ai_pid</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span>/dev/null <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;&amp;</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">||</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">true</span></span>
<span id="cb2-14">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">fi</span></span>
<span id="cb2-15">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rm</span> <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">-f</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$editor</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$staged_diff</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$ai_message</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$ai_status</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$ai_stderr</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span></span>
<span id="cb2-16"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">}</span></span>
<span id="cb2-17"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">trap</span> cleanup EXIT INT TERM</span>
<span id="cb2-18"></span>
<span id="cb2-19"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">git</span> diff <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">--cached</span> <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">--no-ext-diff</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$staged_diff</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span></span>
<span id="cb2-20"></span>
<span id="cb2-21"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$editor</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;&lt;'AI_COMMIT_EDITOR'</span></span>
<span id="cb2-22"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">#!/usr/bin/env bash</span></span>
<span id="cb2-23"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">set -u</span></span>
<span id="cb2-24"></span>
<span id="cb2-25"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">msg_file=$1</span></span>
<span id="cb2-26"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">ai_message=$LAZYGIT_AI_COMMIT_MESSAGE</span></span>
<span id="cb2-27"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">ai_status=$LAZYGIT_AI_COMMIT_STATUS</span></span>
<span id="cb2-28"></span>
<span id="cb2-29"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">while [ ! -s "$ai_status" ]; do</span></span>
<span id="cb2-30"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">  sleep 0.1</span></span>
<span id="cb2-31"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">done</span></span>
<span id="cb2-32"></span>
<span id="cb2-33"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">if [ -s "$ai_message" ]; then</span></span>
<span id="cb2-34"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">  buffer=$(mktemp /tmp/lazygit-ai-commit-editor-buffer.XXXXXX)</span></span>
<span id="cb2-35"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">  {</span></span>
<span id="cb2-36"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">    head -n 1 "$ai_message"</span></span>
<span id="cb2-37"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">    printf '\n'</span></span>
<span id="cb2-38"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">    cat "$msg_file"</span></span>
<span id="cb2-39"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">  } &gt;"$buffer"</span></span>
<span id="cb2-40"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">  cat "$buffer" &gt;"$msg_file"</span></span>
<span id="cb2-41"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">  rm -f "$buffer"</span></span>
<span id="cb2-42"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">elif ! grep -qx 'ok' "$ai_status"; then</span></span>
<span id="cb2-43"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">  cat "$ai_status" &gt;&amp;2</span></span>
<span id="cb2-44"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">fi</span></span>
<span id="cb2-45"></span>
<span id="cb2-46"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">exec vim "$msg_file"</span></span>
<span id="cb2-47"><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">AI_COMMIT_EDITOR</span></span>
<span id="cb2-48"></span>
<span id="cb2-49"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">chmod</span> +x <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$editor</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span></span>
<span id="cb2-50"></span>
<span id="cb2-51"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">command</span> <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">-v</span> codex <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span>/dev/null <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;&amp;</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">;</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">then</span></span>
<span id="cb2-52">  <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">{</span></span>
<span id="cb2-53">    <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">prompt</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'Generate ONLY a one-line Git commit message following Conventional Commits format (type(scope): description). Types: feat, fix, docs, style, refactor, test, chore. Based strictly on the diff from stdin. Output ONLY the message, nothing else.'</span></span>
<span id="cb2-54">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> <span class="ex" style="color: null;
background-color: null;
font-style: inherit;">codex</span> exec <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">-m</span> gpt-5.4-mini <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">--ephemeral</span> <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">--ignore-rules</span> <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">--sandbox</span> read-only <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">-c</span> approval_policy=<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'"never"'</span> <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">-c</span> model_reasoning_effort=<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'"low"'</span> <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">--color</span> never <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">--output-last-message</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$ai_message</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$prompt</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$staged_diff</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span>/dev/null <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$ai_stderr</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">;</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">then</span></span>
<span id="cb2-55">      <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">msg</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$(</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">head</span> <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">-n</span> 1 <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$ai_message</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">)</span></span>
<span id="cb2-56">      <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">[</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">-n</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$msg</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">]</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">;</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">then</span></span>
<span id="cb2-57">        <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">printf</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'%s\n'</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$msg</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$ai_message</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span></span>
<span id="cb2-58">        <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">printf</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'%s\n'</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'ok'</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$ai_status</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span></span>
<span id="cb2-59">      <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span></span>
<span id="cb2-60">        <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">printf</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'%s\n'</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'AI commit message generation returned an empty message; opening editor without AI message.'</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$ai_status</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span></span>
<span id="cb2-61">      <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">fi</span></span>
<span id="cb2-62">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span></span>
<span id="cb2-63">      <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">printf</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'%s\n'</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'AI commit message generation failed; opening editor without AI message.'</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$ai_status</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span></span>
<span id="cb2-64">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">fi</span></span>
<span id="cb2-65">  <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">}</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">&amp;</span></span>
<span id="cb2-66">  <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">ai_pid</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$!</span></span>
<span id="cb2-67"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span></span>
<span id="cb2-68">  <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">printf</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'%s\n'</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'codex not found; opening editor without AI message.'</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$ai_status</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span></span>
<span id="cb2-69"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">fi</span></span>
<span id="cb2-70"></span>
<span id="cb2-71"><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">LAZYGIT_AI_COMMIT_MESSAGE</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$ai_message</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">\</span></span>
<span id="cb2-72">  <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">LAZYGIT_AI_COMMIT_STATUS</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$ai_status</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">\</span></span>
<span id="cb2-73">  <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">GIT_EDITOR</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$editor</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">\</span></span>
<span id="cb2-74">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">git</span> commit</span></code></pre></div></div>
</div>
</div>
</div>
</div>
<p>The AI part is intentionally small. It reads the staged diff from stdin and returns only one line: a Conventional Commits message.</p>
</section>
<section id="where-the-parallelism-comes-from" class="level2">
<h2 class="anchored" data-anchor-id="where-the-parallelism-comes-from">5. Where the Parallelism Comes From</h2>
<p>The background behavior comes from the shell script, not from <code>codex exec</code>.</p>
<p>This block starts the message-generation process in the background:</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb3" style="background: #f1f3f5;"><pre class="sourceCode bash code-with-copy"><code class="sourceCode bash"><span id="cb3-1"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">{</span></span>
<span id="cb3-2">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># codex exec ...</span></span>
<span id="cb3-3"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">}</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">&amp;</span></span>
<span id="cb3-4"><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">ai_pid</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$!</span></span></code></pre></div></div>
<p>Right after that, the script starts <code>git commit</code>:</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb4" style="background: #f1f3f5;"><pre class="sourceCode bash code-with-copy"><code class="sourceCode bash"><span id="cb4-1"><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">LAZYGIT_AI_COMMIT_MESSAGE</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$ai_message</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">\</span></span>
<span id="cb4-2">  <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">LAZYGIT_AI_COMMIT_STATUS</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$ai_status</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">\</span></span>
<span id="cb4-3">  <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">GIT_EDITOR</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$editor</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">\</span></span>
<span id="cb4-4">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">git</span> commit</span></code></pre></div></div>
<p>If the repository has pre-commit hooks, Git runs those hooks before opening the commit-message editor. While that is happening, the background process is already asking <code>codex exec</code> for a message draft.</p>
<p>The temporary editor script waits until the AI process has written a status file:</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb5" style="background: #f1f3f5;"><pre class="sourceCode bash code-with-copy"><code class="sourceCode bash"><span id="cb5-1"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">while</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">[</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">!</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">-s</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$ai_status</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">]</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">;</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">do</span></span>
<span id="cb5-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sleep</span> 0.1</span>
<span id="cb5-3"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">done</span></span></code></pre></div></div>
<p>Then it prepends the generated first line to the commit message file and opens Vim.</p>
<p>If Codex CLI is missing or message generation fails, the script still opens the normal editor, so the fallback is just a manual commit message.</p>
</section>
<section id="why-i-like-this-shape" class="level2">
<h2 class="anchored" data-anchor-id="why-i-like-this-shape">6. Why I Like This Shape</h2>
<p>The biggest win is that pre-commit hook time is no longer pure waiting time. Message generation happens during that window.</p>
<p>I also like that the workflow stays semi-automatic. The AI drafts one line, but I still see the final message in the editor before the commit is created. That fits lazygit well: fast enough for daily use, but still explicit.</p>
</section>
<section id="summary" class="level2">
<h2 class="anchored" data-anchor-id="summary">7. Summary</h2>
<p>This lazygit command now uses <code>codex exec</code> for non-interactive commit-message generation.</p>
<p>The important implementation detail is the shell script around it. The script backgrounds the AI generation, starts <code>git commit</code>, lets pre-commit hooks run in parallel with generation, and then opens Vim with the generated message draft.</p>
<p>Codex CLI may also get different limits or billing rules someday. If that happens, I will probably look at a local LLM version for this helper. For now, this small <code>codex exec</code> workflow is a good fit.</p>


<div class="social-share"><a href="https://twitter.com/share?url=https%3A%2F%2Fi9wa4.github.io%2Fen%2Fblog%2F2026-05-15-lazygit-commit-messages-with-codex-exec.html&amp;text=Generate%20lazygit%20Commit%20Messages%20with%20codex%20exec%20%E2%80%93%20uma-chan%E2%80%99s%20page" target="_blank" class="twitter"><i class="bi bi-twitter-x"></i></a><a href="https://bsky.app/intent/compose?text=Generate%20lazygit%20Commit%20Messages%20with%20codex%20exec%20%E2%80%93%20uma-chan%E2%80%99s%20page%20https%3A%2F%2Fi9wa4.github.io%2Fen%2Fblog%2F2026-05-15-lazygit-commit-messages-with-codex-exec.html" target="_blank" class="bsky"><i class="bi bi-bluesky"></i></a><a href="https://www.linkedin.com/shareArticle?url=https%3A%2F%2Fi9wa4.github.io%2Fen%2Fblog%2F2026-05-15-lazygit-commit-messages-with-codex-exec.html&amp;title=Generate%20lazygit%20Commit%20Messages%20with%20codex%20exec%20%E2%80%93%20uma-chan%E2%80%99s%20page" target="_blank" class="linkedin"><i class="bi bi-linkedin"></i></a></div>
</section>

 ]]></description>
  <category>blog</category>
  <category>tech-ai</category>
  <guid>https://i9wa4.github.io/en/blog/2026-05-15-lazygit-commit-messages-with-codex-exec.html</guid>
  <pubDate>Thu, 14 May 2026 15:01:02 GMT</pubDate>
  <media:content url="https://i9wa4.github.io/assets/common/icon_hhkb3_large.jpg" medium="image" type="image/jpeg"/>
</item>
<item>
  <title>lazygit のコミットメッセージを codex exec で生成する</title>
  <dc:creator>uma-chan </dc:creator>
  <link>https://i9wa4.github.io/zenn/2026-05-14-lazygit-ai-commit-codex-exec.html</link>
  <description><![CDATA[ 





<section id="zenn-リンク先" class="level2">
<h2 class="anchored" data-anchor-id="zenn-リンク先">Zenn リンク先</h2>
<p>この記事は Zenn で公開されています。</p>
<p><a href="https://zenn.dev/i9wa4/articles/2026-05-14-lazygit-ai-commit-codex-exec">lazygit のコミットメッセージを <code>codex exec</code> で生成する</a></p>


</section>

 ]]></description>
  <category>zenn</category>
  <category>lazygit</category>
  <category>codexcli</category>
  <category>codex</category>
  <guid>https://i9wa4.github.io/zenn/2026-05-14-lazygit-ai-commit-codex-exec.html</guid>
  <pubDate>Thu, 14 May 2026 13:45:00 GMT</pubDate>
  <media:content url="https://i9wa4.github.io/assets/common/zenn-ogp.png" medium="image" type="image/png" height="76" width="144"/>
</item>
<item>
  <title>Vim の window resize を連打しやすくする</title>
  <dc:creator>uma-chan </dc:creator>
  <link>https://i9wa4.github.io/blog/2026-05-10-vim-window-resize-repeat.html</link>
  <description><![CDATA[ 





<section id="はじめに" class="level2">
<h2 class="anchored" data-anchor-id="はじめに">1. はじめに</h2>
<p>Vim の window resize は標準で以下のキーバインドが用意されています。</p>
<pre class="vim"><code>&lt;C-w&gt;-
&lt;C-w&gt;+
&lt;C-w&gt;&lt;
&lt;C-w&gt;&gt;</code></pre>
<p>それぞれ window の高さや幅を 1 ずつ変更する操作です。</p>
<p>標準機能としては十分なのですが、少し大きめに resize したいときに毎回 <code>&lt;C-w&gt;</code> を押すのがやや面倒です。</p>
<pre class="vim"><code>&lt;C-w&gt;-&lt;C-w&gt;-&lt;C-w&gt;-</code></pre>
<p>気持ちとしては、最初の <code>&lt;C-w&gt;</code> だけ押して、あとは resize 方向のキーを連打したい。</p>
<pre class="vim"><code>&lt;C-w&gt;---</code></pre>
<p>これを実現する mapping のメモです。</p>
</section>
<section id="設定" class="level2">
<h2 class="anchored" data-anchor-id="設定">2. 設定</h2>
<p><code>vimrc</code> に以下のように書きます。</p>
<div class="code-with-filename">
<div class="code-with-filename-file">
<pre><strong>vimrc</strong></pre>
</div>
<pre class="vim" data-filename="vimrc"><code>" Resize Window
nmap &lt;C-w&gt;-    &lt;C-w&gt;-&lt;SID&gt;ws
nmap &lt;C-w&gt;+    &lt;C-w&gt;+&lt;SID&gt;ws
nmap &lt;C-w&gt;&lt;lt&gt; &lt;C-w&gt;&lt;lt&gt;&lt;SID&gt;ws
nmap &lt;C-w&gt;&gt;    &lt;C-w&gt;&gt;&lt;SID&gt;ws
nmap &lt;SID&gt;ws &lt;Nop&gt;
nnoremap &lt;script&gt; &lt;SID&gt;ws-    &lt;C-w&gt;-&lt;SID&gt;ws
nnoremap &lt;script&gt; &lt;SID&gt;ws+    &lt;C-w&gt;+&lt;SID&gt;ws
nnoremap &lt;script&gt; &lt;SID&gt;ws&lt;lt&gt; &lt;C-w&gt;&lt;lt&gt;&lt;SID&gt;ws
nnoremap &lt;script&gt; &lt;SID&gt;ws&gt;    &lt;C-w&gt;&gt;&lt;SID&gt;ws</code></pre>
</div>
<p>これで以下のように resize できます。</p>
<pre class="vim"><code>&lt;C-w&gt;----
&lt;C-w&gt;++++
&lt;C-w&gt;&lt;&lt;&lt;
&lt;C-w&gt;&gt;&gt;&gt;</code></pre>
<p><code>&lt;</code> は key notation の開始記号として扱われるので <code>&lt;lt&gt;</code> と書きます。 一方で <code>&gt;</code> はそのまま書けます。</p>
</section>
<section id="仕組み" class="level2">
<h2 class="anchored" data-anchor-id="仕組み">3. 仕組み</h2>
<p>最初の mapping は標準の resize 操作を実行したあと、<code>&lt;SID&gt;ws</code> という script-local な中継地点に入ります。</p>
<pre class="vim"><code>nmap &lt;C-w&gt;- &lt;C-w&gt;-&lt;SID&gt;ws</code></pre>
<p><code>&lt;SID&gt;ws</code> 自体は何もしない mapping です。</p>
<pre class="vim"><code>nmap &lt;SID&gt;ws &lt;Nop&gt;</code></pre>
<p>ただし、<code>&lt;SID&gt;ws-</code> や <code>&lt;SID&gt;ws+</code> のような続きの mapping も定義しておきます。 そのため、<code>&lt;SID&gt;ws</code> に入った直後に <code>-</code> を押すと、もう一度 <code>&lt;C-w&gt;-</code> が実行されます。</p>
<pre class="vim"><code>nnoremap &lt;script&gt; &lt;SID&gt;ws- &lt;C-w&gt;-&lt;SID&gt;ws</code></pre>
<p>そして RHS の最後でまた <code>&lt;SID&gt;ws</code> に戻るので、<code>-</code> を押し続けるだけで resize を繰り返せます。</p>
<p><code>&lt;script&gt;</code> を付けているのは、RHS の <code>&lt;SID&gt;ws</code> だけをこの script-local mapping として解決したいからです。 通常のユーザー定義 mapping と混ざりにくくなります。</p>
</section>
<section id="キーを変える場合" class="level2">
<h2 class="anchored" data-anchor-id="キーを変える場合">4. キーを変える場合</h2>
<p>標準の <code>&lt;C-w&gt;-</code>, <code>&lt;C-w&gt;+</code>, <code>&lt;C-w&gt;&lt;</code>, <code>&lt;C-w&gt;&gt;</code> を尊重したい場合は上の設定でよいです。</p>
<p>もし Vim のデフォルトにこだわらないなら、<code>H</code>, <code>J</code>, <code>K</code>, <code>L</code> に割り当てる形にもできます。</p>
<div class="code-with-filename">
<div class="code-with-filename-file">
<pre><strong>vimrc</strong></pre>
</div>
<pre class="vim" data-filename="vimrc"><code>" Resize Window
nmap &lt;C-w&gt;H &lt;C-w&gt;&lt;lt&gt;&lt;SID&gt;ws
nmap &lt;C-w&gt;J &lt;C-w&gt;-&lt;SID&gt;ws
nmap &lt;C-w&gt;K &lt;C-w&gt;+&lt;SID&gt;ws
nmap &lt;C-w&gt;L &lt;C-w&gt;&gt;&lt;SID&gt;ws
nmap &lt;SID&gt;ws &lt;Nop&gt;
nnoremap &lt;script&gt; &lt;SID&gt;wsH &lt;C-w&gt;&lt;lt&gt;&lt;SID&gt;ws
nnoremap &lt;script&gt; &lt;SID&gt;wsJ &lt;C-w&gt;-&lt;SID&gt;ws
nnoremap &lt;script&gt; &lt;SID&gt;wsK &lt;C-w&gt;+&lt;SID&gt;ws
nnoremap &lt;script&gt; &lt;SID&gt;wsL &lt;C-w&gt;&gt;&lt;SID&gt;ws</code></pre>
</div>
<p>ただし、この形は <code>&lt;C-w&gt;H</code> などの Vim 標準の window 移動系キーバインドを上書きします。 そのため、標準キーバインドを残したい場合は <code>-</code>, <code>+</code>, <code>&lt;</code>, <code>&gt;</code> のままにするのが無難です。</p>
</section>
<section id="おわりに" class="level2">
<h2 class="anchored" data-anchor-id="おわりに">5. おわりに</h2>
<p>私の dotfiles では今は不要になったので外しましたが、設定としてはちゃんと動くのでメモとして残しておきます。</p>


<div class="social-share"><a href="https://twitter.com/share?url=https%3A%2F%2Fi9wa4.github.io%2Fblog%2F2026-05-10-vim-window-resize-repeat.html&amp;text=Vim%20%E3%81%AE%20window%20resize%20%E3%82%92%E9%80%A3%E6%89%93%E3%81%97%E3%82%84%E3%81%99%E3%81%8F%E3%81%99%E3%82%8B%20%E2%80%93%20uma-chan%E2%80%99s%20page" target="_blank" class="twitter"><i class="bi bi-twitter-x"></i></a><a href="https://bsky.app/intent/compose?text=Vim%20%E3%81%AE%20window%20resize%20%E3%82%92%E9%80%A3%E6%89%93%E3%81%97%E3%82%84%E3%81%99%E3%81%8F%E3%81%99%E3%82%8B%20%E2%80%93%20uma-chan%E2%80%99s%20page%20https%3A%2F%2Fi9wa4.github.io%2Fblog%2F2026-05-10-vim-window-resize-repeat.html" target="_blank" class="bsky"><i class="bi bi-bluesky"></i></a><a href="https://www.linkedin.com/shareArticle?url=https%3A%2F%2Fi9wa4.github.io%2Fblog%2F2026-05-10-vim-window-resize-repeat.html&amp;title=Vim%20%E3%81%AE%20window%20resize%20%E3%82%92%E9%80%A3%E6%89%93%E3%81%97%E3%82%84%E3%81%99%E3%81%8F%E3%81%99%E3%82%8B%20%E2%80%93%20uma-chan%E2%80%99s%20page" target="_blank" class="linkedin"><i class="bi bi-linkedin"></i></a></div>
</section>

 ]]></description>
  <category>blog</category>
  <category>tech-vim</category>
  <guid>https://i9wa4.github.io/blog/2026-05-10-vim-window-resize-repeat.html</guid>
  <pubDate>Sun, 10 May 2026 10:00:00 GMT</pubDate>
  <media:content url="https://i9wa4.github.io/assets/common/icon_hhkb3_large.jpg" medium="image" type="image/jpeg"/>
</item>
<item>
  <title>SKK + 絵文字辞書でどこからでも絵文字を打つ</title>
  <dc:creator>uma-chan </dc:creator>
  <link>https://i9wa4.github.io/blog/2026-04-30-type-emoji-everywhere-with-skk.html</link>
  <description><![CDATA[ 





<section id="課題絵文字を打つのが面倒" class="level2">
<h2 class="anchored" data-anchor-id="課題絵文字を打つのが面倒">1. 課題：絵文字を打つのが面倒</h2>
<p>絵文字を打つとき毎回IMEで適当にキーワードを入力したり、Slackであれば <code>:</code> で絵文字検索したりしていました。</p>
<p>いつでもどこでも同じ方法で絵文字を入力するために SKK を使って実現することにしました。</p>
</section>
<section id="英語名を覚えるとどこでも打てる" class="level2">
<h2 class="anchored" data-anchor-id="英語名を覚えるとどこでも打てる">2. 英語名を覚えるとどこでも打てる</h2>
<p>SKK には abbrev モードという入力モードがあります。</p>
<p><code>/</code> を打って英語キーワードを入力すると、辞書に登録されたエントリを変換候補として引けます。</p>
<pre class="text"><code>/tada          → 🎉
/partying_face → 🥳
/fire          → 🔥</code></pre>
<p>スニペット展開に近い感覚です。<code>tada</code> と打てば変換できますが、そのためには <code>tada</code> というキーワードが登録されていることを知っている必要があります。結局は英語名を覚えることが前提です。</p>
<p><a href="https://github.com/ikatyang/emoji-cheat-sheet">emoji-cheat-sheet</a> は絵文字の英語名を一覧できるリファレンスです。「この絵文字は英語で何と呼ぶか」をここで確認しながら覚えておけば、SKK が動いている環境ならどこでも絵文字が打てるようになります。</p>
<p>スマホでもキーワードを覚えていれば絵文字をヒットさせることができる場合があるので、その点でも便利です。</p>
</section>
<section id="skk-emoji-jisyo" class="level2">
<h2 class="anchored" data-anchor-id="skk-emoji-jisyo">3. skk-emoji-jisyo</h2>
<p><a href="https://github.com/uasi/skk-emoji-jisyo">skk-emoji-jisyo</a> は SKK 用の絵文字辞書です。gemoji の shortcode 名をキーとした英語のみのエントリで構成されています。</p>
<pre class="text"><code>tada /🎉/
partying_face /🥳/
fire /🔥/
clinking_glasses /🥂/
star /⭐/</code></pre>
<p>この辞書を追加しておくことで、abbrev モードでの英語変換が機能します。</p>
</section>
<section id="クライアント別設定" class="level2">
<h2 class="anchored" data-anchor-id="クライアント別設定">4. クライアント別設定</h2>
<section id="skkeleton-vim-neovim" class="level3">
<h3 class="anchored" data-anchor-id="skkeleton-vim-neovim">4.1. skkeleton (Vim / Neovim)</h3>
<p><a href="https://github.com/vim-skk/skkeleton">skkeleton</a> は Vim / Neovim 用の SKK プラグインです。</p>
<p>私の環境では <a href="https://github.com/Shougo/dpp.vim">dpp.vim</a> で辞書リポジトリ自体をプラグインとして管理しています。<code>skk-dev/dict</code> と <code>uasi/skk-emoji-jisyo</code> を dpp に登録しておくと <code>$XDG_CACHE_HOME/dpp/repos/</code> 以下にクローンされるので、そのパスを <code>globalDictionaries</code> に渡しています。</p>
<pre class="vim"><code>let s:skk_dev_path = $XDG_CACHE_HOME-&gt;expand() .. '/dpp/repos/github.com/skk-dev/dict'
let s:skk_emoji_path = $XDG_CACHE_HOME-&gt;expand() .. '/dpp/repos/github.com/uasi/skk-emoji-jisyo'
call skkeleton#config({
\   'globalDictionaries': [
\     s:skk_dev_path .. '/SKK-JISYO.L',
\     s:skk_dev_path .. '/SKK-JISYO.jinmei',
\     s:skk_dev_path .. '/SKK-JISYO.assoc',
\     s:skk_emoji_path .. '/SKK-JISYO.emoji.utf8',
\   ],
\   'userDictionary': '~/path/to/skkdict.utf8',
\ })
call skkeleton#register_keymap('input', ';', 'henkanPoint')
imap &lt;C-k&gt; &lt;Plug&gt;(skkeleton-enable)</code></pre>
</section>
<section id="macskk-macos" class="level3">
<h3 class="anchored" data-anchor-id="macskk-macos">4.2. macSKK (macOS)</h3>
<p><a href="https://github.com/mtgto/macSKK">macSKK</a> は macOS の入力ソースとして動作する SKK クライアントです。IME として登録するため、ブラウザ・Slack・ターミナル・あらゆるアプリで同じ辞書が使えます。</p>
<p>macSKK は sandbox の制約で <code>~/Library/Containers/net.mtgto.inputmethod.macSKK/Data/Documents/Dictionaries/</code> 以下にしか辞書ファイルを置けません。</p>
<p>私は Nix home-manager の activation スクリプトで dpp キャッシュから自動コピーしています。</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb4" style="background: #f1f3f5;"><pre class="sourceCode nix code-with-copy"><code class="sourceCode nix"><span id="cb4-1">home<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span>activation<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span>setupMacSkkDict = lib<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span>hm<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span>dag<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span>entryAfter <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"writeBoundary"</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">]</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">''</span></span>
<span id="cb4-2"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">  macSkkDir="$HOME/Library/Containers/net.mtgto.inputmethod.macSKK/Data/Documents/Dictionaries"</span></span>
<span id="cb4-3"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">  dppSkkDev="</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">${</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">XDG_CACHE_HOME</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:-</span>$<span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">HOME/.cache</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">/dpp/repos/github.com/skk-dev/dict"</span></span>
<span id="cb4-4"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">  dppSkkEmoji="</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">${</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">XDG_CACHE_HOME</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:-</span>$<span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">HOME/.cache</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">/dpp/repos/github.com/uasi/skk-emoji-jisyo"</span></span>
<span id="cb4-5"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">  mkdir -p "$macSkkDir"</span></span>
<span id="cb4-6"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">  [[ -f "$dppSkkDev/SKK-JISYO.L" ]] &amp;&amp; cp -f "$dppSkkDev/SKK-JISYO.L" "$macSkkDir/SKK-JISYO.L"</span></span>
<span id="cb4-7"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">  [[ -f "$dppSkkEmoji/SKK-JISYO.emoji.utf8" ]] &amp;&amp; cp -f "$dppSkkEmoji/SKK-JISYO.emoji.utf8" "$macSkkDir/SKK-JISYO.emoji.utf8"</span></span>
<span id="cb4-8"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">''</span>;</span></code></pre></div></div>
<p><code>home-manager switch</code> を実行するだけで辞書が同期されます。dpp を一度でも起動してキャッシュが作られていることが前提です。</p>
<p>Nix を使っていない場合は、手動で <code>SKK-JISYO.emoji.utf8</code> を上記のディレクトリにコピーすれば動きます。</p>
</section>
</section>
<section id="まとめ" class="level2">
<h2 class="anchored" data-anchor-id="まとめ">5. まとめ</h2>
<ul>
<li>SKK abbrev モード (<code>/</code> + 英語名) で絵文字変換できる</li>
<li>英語名を覚えることが本質で、<a href="https://github.com/ikatyang/emoji-cheat-sheet">emoji-cheat-sheet</a> がその辞書になる</li>
<li><a href="https://github.com/uasi/skk-emoji-jisyo">skk-emoji-jisyo</a> を追加することで gemoji shortcode 名で絵文字を変換できるようになる</li>
<li>macSKK なら OS レベルで動くのでどのアプリでも使える</li>
<li>skkeleton なら Vim / Neovim 内で完結する</li>
</ul>


<div class="social-share"><a href="https://twitter.com/share?url=https%3A%2F%2Fi9wa4.github.io%2Fblog%2F2026-04-30-type-emoji-everywhere-with-skk.html&amp;text=SKK%20%2B%20%E7%B5%B5%E6%96%87%E5%AD%97%E8%BE%9E%E6%9B%B8%E3%81%A7%E3%81%A9%E3%81%93%E3%81%8B%E3%82%89%E3%81%A7%E3%82%82%E7%B5%B5%E6%96%87%E5%AD%97%E3%82%92%E6%89%93%E3%81%A4%20%E2%80%93%20uma-chan%E2%80%99s%20page" target="_blank" class="twitter"><i class="bi bi-twitter-x"></i></a><a href="https://bsky.app/intent/compose?text=SKK%20%2B%20%E7%B5%B5%E6%96%87%E5%AD%97%E8%BE%9E%E6%9B%B8%E3%81%A7%E3%81%A9%E3%81%93%E3%81%8B%E3%82%89%E3%81%A7%E3%82%82%E7%B5%B5%E6%96%87%E5%AD%97%E3%82%92%E6%89%93%E3%81%A4%20%E2%80%93%20uma-chan%E2%80%99s%20page%20https%3A%2F%2Fi9wa4.github.io%2Fblog%2F2026-04-30-type-emoji-everywhere-with-skk.html" target="_blank" class="bsky"><i class="bi bi-bluesky"></i></a><a href="https://www.linkedin.com/shareArticle?url=https%3A%2F%2Fi9wa4.github.io%2Fblog%2F2026-04-30-type-emoji-everywhere-with-skk.html&amp;title=SKK%20%2B%20%E7%B5%B5%E6%96%87%E5%AD%97%E8%BE%9E%E6%9B%B8%E3%81%A7%E3%81%A9%E3%81%93%E3%81%8B%E3%82%89%E3%81%A7%E3%82%82%E7%B5%B5%E6%96%87%E5%AD%97%E3%82%92%E6%89%93%E3%81%A4%20%E2%80%93%20uma-chan%E2%80%99s%20page" target="_blank" class="linkedin"><i class="bi bi-linkedin"></i></a></div>
</section>

 ]]></description>
  <category>blog</category>
  <category>tech</category>
  <guid>https://i9wa4.github.io/blog/2026-04-30-type-emoji-everywhere-with-skk.html</guid>
  <pubDate>Thu, 30 Apr 2026 04:49:52 GMT</pubDate>
  <media:content url="https://i9wa4.github.io/assets/common/icon_hhkb3_large.jpg" medium="image" type="image/jpeg"/>
</item>
<item>
  <title>AIがドキュメントを書き散らかさないための mkmd スクリプトの紹介</title>
  <dc:creator>uma-chan </dc:creator>
  <link>https://i9wa4.github.io/blog/2026-03-22-mkmd-mktemp-wrapper-for-ai-agents.html</link>
  <description><![CDATA[ 





<section id="課題aiエージェントの作業ファイルが散らかる" class="level2">
<h2 class="anchored" data-anchor-id="課題aiエージェントの作業ファイルが散らかる">1. 課題：AIエージェントの作業ファイルが散らかる</h2>
<p>Claude Code や Codex CLI を日常的に使っていると、調査メモ、計画書、レビュー結果など、セッション中だけ使う一時的なMarkdownファイルが大量に生まれます。</p>
<p>これらをリポジトリ内に作ると <code>.gitignore</code> 管理が面倒ですし、<code>/tmp/</code> に作ると再起動で消えます。かといって毎回手動でパスを考えるのも非効率です。</p>
<p>欲しかったのは以下を満たすツールです。</p>
<ul>
<li>git リポジトリ汚さない</li>
<li>プロジェクトごとに自動分類される</li>
<li>日付とブランチでセッションが区別できる</li>
<li>ファイル名が衝突しない</li>
<li>コマンド一発で作れる</li>
</ul>
</section>
<section id="どう便利か" class="level2">
<h2 class="anchored" data-anchor-id="どう便利か">2. どう便利か</h2>
<section id="あとから探せる" class="level3">
<h3 class="anchored" data-anchor-id="あとから探せる">2.1. あとから探せる</h3>
<p>作業ファイルが <code>~/.local/state/mkmd/</code> 以下にプロジェクト別・日付別で整理されるので、「あの調査結果どこだっけ」が <code>ls</code> 一発で解決します。</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb1" style="background: #f1f3f5;"><pre class="sourceCode bash code-with-copy"><code class="sourceCode bash"><span id="cb1-1"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">~/.local/state/mkmd/</span></span>
<span id="cb1-2"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">├──</span> i9wa4-dotfiles/</span>
<span id="cb1-3"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">│</span>   └── 2026-03-22-main/</span>
<span id="cb1-4"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">│</span>       ├── research/</span>
<span id="cb1-5"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">│</span>       │   └── nix-investigation-aB3xKq.md</span>
<span id="cb1-6"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">│</span>       └── plans/</span>
<span id="cb1-7"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">│</span>           └── plan-Xk9mZw.md</span>
<span id="cb1-8"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">├──</span> i9wa4-i9wa4.github.io/</span>
<span id="cb1-9"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">│</span>   └── 2026-03-22-feat-auth/</span>
<span id="cb1-10"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">│</span>       └── draft/</span>
<span id="cb1-11"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">│</span>           └── design-doc-pQ7rLs.md</span>
<span id="cb1-12"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">└──</span> mycompany-api/</span>
<span id="cb1-13">    <span class="ex" style="color: null;
background-color: null;
font-style: inherit;">└──</span> 2026-03-21-issue-42/</span>
<span id="cb1-14">        <span class="ex" style="color: null;
background-color: null;
font-style: inherit;">└──</span> reviews/</span>
<span id="cb1-15">            <span class="ex" style="color: null;
background-color: null;
font-style: inherit;">└──</span> completion-nW2vHj.md</span></code></pre></div></div>
<p>ディレクトリ名を見ればどのリポジトリの、いつの、どのブランチの作業かわかります。 ブランチ名が含まれるので、同じ日に複数の Issue を行き来しても混ざりません。</p>
</section>
<section id="リポジトリが汚れない" class="level3">
<h3 class="anchored" data-anchor-id="リポジトリが汚れない">2.2. リポジトリが汚れない</h3>
<p><code>$XDG_STATE_HOME</code> (デフォルト <code>~/.local/state</code>) に出力するので git リポジトリには一切触れません。<code>.gitignore</code> に追加する必要もなく、リポジトリは常にクリーンに保てます。</p>
</section>
<section id="aiエージェントが自律的に使える" class="level3">
<h3 class="anchored" data-anchor-id="aiエージェントが自律的に使える">2.3. AIエージェントが自律的に使える</h3>
<p>CLAUDE.md / AGENTS.md に一行書いておくだけで、エージェントが調査・計画・レビューの各フェーズで適切にファイルを作ってくれます。</p>
<p>エージェントが自分で</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb2" style="background: #f1f3f5;"><pre class="sourceCode bash code-with-copy"><code class="sourceCode bash"><span id="cb2-1"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">mkmd</span> <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">--dir</span> research <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">--label</span> api-investigation</span></code></pre></div></div>
<p>を実行し、結果をそのファイルに書き込み、後続のタスクで参照してくれます。</p>
</section>
<section id="消しやすい" class="level3">
<h3 class="anchored" data-anchor-id="消しやすい">2.4. 消しやすい</h3>
<p>不要になったら日付ディレクトリごと消せます。</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb3" style="background: #f1f3f5;"><pre class="sourceCode bash code-with-copy"><code class="sourceCode bash"><span id="cb3-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rm</span> <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">-rf</span> ~/.local/state/mkmd/i9wa4-dotfiles/2026-03-20-<span class="pp" style="color: #AD0000;
background-color: null;
font-style: inherit;">*</span></span></code></pre></div></div>
<p>プロジェクトごと消すのも簡単です。全部消しても何も壊れません。</p>
</section>
</section>
<section id="mkmdmktemp-の-markdown-wrapper" class="level2">
<h2 class="anchored" data-anchor-id="mkmdmktemp-の-markdown-wrapper">3. mkmd：mktemp の Markdown wrapper</h2>
<p><code>mktemp</code> は一時ファイルをアトミックに作成する UNIX の基本コマンドです。</p>
<p><code>mkmd</code> はその wrapper として作っています。</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb4" style="background: #f1f3f5;"><pre class="sourceCode bash code-with-copy"><code class="sourceCode bash"><span id="cb4-1"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">$</span> mkmd <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">--dir</span> research <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">--label</span> api-investigation</span>
<span id="cb4-2"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">~/.local/state/mkmd/i9wa4-dotfiles/2026-03-22-main/research/api-investigation-xEZZqX.md</span></span></code></pre></div></div>
<p>生成されるパスの構造はこうなっています。</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb5" style="background: #f1f3f5;"><pre class="sourceCode bash code-with-copy"><code class="sourceCode bash"><span id="cb5-1"><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$MKMD_BASE_DIR</span><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">/</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span>owner<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span>-<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span>repo<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span>/YYYY-MM-DD-<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span>branch<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span>/<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span>DIR<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span>/<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span>LABEL<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span>-<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span>XXXXXX<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span>.md</span></code></pre></div></div>
<table class="caption-top table">
<thead>
<tr class="header">
<th>セグメント</th>
<th>決定方法</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td><code>MKMD_BASE_DIR</code></td>
<td>環境変数 (デフォルト: <code>$XDG_STATE_HOME/mkmd</code>)</td>
</tr>
<tr class="even">
<td><code>owner-repo</code></td>
<td><code>git remote get-url origin</code> から自動抽出</td>
</tr>
<tr class="odd">
<td><code>YYYY-MM-DD</code></td>
<td>実行日</td>
</tr>
<tr class="even">
<td><code>branch</code></td>
<td><code>git rev-parse --abbrev-ref HEAD</code></td>
</tr>
<tr class="odd">
<td><code>DIR</code></td>
<td><code>--dir</code> 引数</td>
</tr>
<tr class="even">
<td><code>LABEL-XXXXXX</code></td>
<td><code>--label</code> 引数 + <code>mktemp</code> のランダム文字列</td>
</tr>
</tbody>
</table>
<p>git リポジトリ外で実行した場合は <code>local-&lt;dirname&gt;/...-local/</code> にフォールバックします。</p>
</section>
<section id="スクリプト全文" class="level2">
<h2 class="anchored" data-anchor-id="スクリプト全文">4. スクリプト全文</h2>
<p>PATH の通ったディレクトリに置いて <code>chmod +x</code> するだけで使えます。</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb6" style="background: #f1f3f5;"><pre class="sourceCode bash code-with-copy"><code class="sourceCode bash"><span id="cb6-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">chmod</span> +x mkmd</span></code></pre></div></div>
<div class="code-with-filename">
<div class="code-with-filename-file">
<pre><strong>mkmd</strong></pre>
</div>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb7" data-filename="mkmd" style="background: #f1f3f5;"><pre class="sourceCode bash code-with-copy"><code class="sourceCode bash"><span id="cb7-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#!/usr/bin/env bash</span></span>
<span id="cb7-2"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">set</span> <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">-o</span> errexit</span>
<span id="cb7-3"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">set</span> <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">-o</span> nounset</span>
<span id="cb7-4"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">set</span> <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">-o</span> pipefail</span>
<span id="cb7-5"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">set</span> <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">-o</span> posix</span>
<span id="cb7-6"></span>
<span id="cb7-7"><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">BASE_DIR</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">${MKMD_BASE_DIR</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:-</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">${XDG_STATE_HOME</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:-</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$HOME</span>/.local/state<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">}</span>/mkmd<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">}</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span></span>
<span id="cb7-8"></span>
<span id="cb7-9"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print_usage()</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">{</span></span>
<span id="cb7-10">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;&lt;EOF</span></span>
<span id="cb7-11"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">Usage:</span></span>
<span id="cb7-12"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">  mkmd --dir DIR --label LABEL</span></span>
<span id="cb7-13"></span>
<span id="cb7-14"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">mktemp wrapper that creates a markdown working file.</span></span>
<span id="cb7-15"></span>
<span id="cb7-16"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">Creates:</span></span>
<span id="cb7-17"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">  </span><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">\$</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">MKMD_BASE_DIR/&lt;owner&gt;-&lt;repo&gt;/YYYY-MM-DD-&lt;branch&gt;/&lt;DIR&gt;/&lt;LABEL&gt;-&lt;XXXXXX&gt;.md</span></span>
<span id="cb7-18"></span>
<span id="cb7-19"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">  Base directory: </span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">${BASE_DIR}</span></span>
<span id="cb7-20"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">  Works in git repos (uses owner/repo from remote URL) and outside git (uses "local"/dirname).</span></span>
<span id="cb7-21"></span>
<span id="cb7-22"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">Environment:</span></span>
<span id="cb7-23"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">  MKMD_BASE_DIR  Override base directory (default: </span><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">\$</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">XDG_STATE_HOME/mkmd)</span></span>
<span id="cb7-24"></span>
<span id="cb7-25"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">Options:</span></span>
<span id="cb7-26"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">  --dir DIR      Directory name under the daily session</span></span>
<span id="cb7-27"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">  --label LABEL  File label included in the filename</span></span>
<span id="cb7-28"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">  -h, --help     Show this help and exit</span></span>
<span id="cb7-29"><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">EOF</span></span>
<span id="cb7-30"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">}</span></span>
<span id="cb7-31"></span>
<span id="cb7-32"><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">LABEL</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span></span>
<span id="cb7-33"><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">DIR</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span></span>
<span id="cb7-34"></span>
<span id="cb7-35"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Parse arguments</span></span>
<span id="cb7-36"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">while</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">[[</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$#</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">-gt</span> 0 <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">]];</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">do</span></span>
<span id="cb7-37">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">case</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$1</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span></span>
<span id="cb7-38">  <span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">-h</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">|</span> <span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">--help</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">)</span></span>
<span id="cb7-39">    <span class="ex" style="color: null;
background-color: null;
font-style: inherit;">print_usage</span></span>
<span id="cb7-40">    <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">exit</span> 0</span>
<span id="cb7-41">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">;;</span></span>
<span id="cb7-42">  <span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">--dir</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">)</span></span>
<span id="cb7-43">    <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">DIR</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$2</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span></span>
<span id="cb7-44">    <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">shift</span> 2</span>
<span id="cb7-45">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">;;</span></span>
<span id="cb7-46">  <span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">--label</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">)</span></span>
<span id="cb7-47">    <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">LABEL</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$2</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span></span>
<span id="cb7-48">    <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">shift</span> 2</span>
<span id="cb7-49">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">;;</span></span>
<span id="cb7-50">  <span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">-</span><span class="pp" style="color: #AD0000;
background-color: null;
font-style: inherit;">*</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">)</span></span>
<span id="cb7-51">    <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">echo</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Unknown option: </span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$1</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;&amp;</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span></span>
<span id="cb7-52">    <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">exit</span> 1</span>
<span id="cb7-53">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">;;</span></span>
<span id="cb7-54">  <span class="pp" style="color: #AD0000;
background-color: null;
font-style: inherit;">*</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">)</span></span>
<span id="cb7-55">    <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">echo</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Error: Unknown argument: </span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$1</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;&amp;</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span></span>
<span id="cb7-56">    <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">exit</span> 1</span>
<span id="cb7-57">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">;;</span></span>
<span id="cb7-58">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">esac</span></span>
<span id="cb7-59"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">done</span></span>
<span id="cb7-60"></span>
<span id="cb7-61"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Validate DIR and LABEL</span></span>
<span id="cb7-62"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">[[</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">-z</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$DIR</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">||</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">-z</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$LABEL</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">]];</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">then</span></span>
<span id="cb7-63">  <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">echo</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Error: --dir and --label are required"</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;&amp;</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span></span>
<span id="cb7-64">  <span class="ex" style="color: null;
background-color: null;
font-style: inherit;">print_usage</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;&amp;</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span></span>
<span id="cb7-65">  <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">exit</span> 1</span>
<span id="cb7-66"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">fi</span></span>
<span id="cb7-67"></span>
<span id="cb7-68"><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">repo_root</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$(</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">git</span> rev-parse <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">--show-toplevel</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span>/dev/null <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">||</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">true</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">)</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span></span>
<span id="cb7-69"></span>
<span id="cb7-70"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">[[</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">-n</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$repo_root</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">]];</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">then</span></span>
<span id="cb7-71">  <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">remote_url</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$(</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">git</span> remote get-url origin <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span>/dev/null <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">||</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">true</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">)</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span></span>
<span id="cb7-72">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">[[</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">-n</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$remote_url</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">]];</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">then</span></span>
<span id="cb7-73">    <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Extract owner/repo from remote URL (handles both SSH and HTTPS)</span></span>
<span id="cb7-74">    <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">remote_url</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">${remote_url</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%</span>.git<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">}</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span></span>
<span id="cb7-75">    <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">project_name</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">${remote_url</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">##</span><span class="pp" style="color: #AD0000;
background-color: null;
font-style: inherit;">*</span>/<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">}</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span></span>
<span id="cb7-76">    <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">remote_url</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">${remote_url</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%</span>/<span class="pp" style="color: #AD0000;
background-color: null;
font-style: inherit;">*</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">}</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span></span>
<span id="cb7-77">    <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">project_owner</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">${remote_url</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">##</span><span class="pp" style="color: #AD0000;
background-color: null;
font-style: inherit;">*</span>[:/]<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">}</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span></span>
<span id="cb7-78">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span></span>
<span id="cb7-79">    <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">project_owner</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"local"</span></span>
<span id="cb7-80">    <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">project_name</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$(</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">basename</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$repo_root</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">)</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span></span>
<span id="cb7-81">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">fi</span></span>
<span id="cb7-82">  <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">branch_name</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$(</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">git</span> rev-parse <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">--abbrev-ref</span> HEAD <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span>/dev/null <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">||</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">echo</span> unknown<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">)</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span></span>
<span id="cb7-83">  <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">branch_name</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">${branch_name</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">//</span><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">\/</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span>-<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">}</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span></span>
<span id="cb7-84"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span></span>
<span id="cb7-85">  <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">project_owner</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"local"</span></span>
<span id="cb7-86">  <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">project_name</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$(</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">basename</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$(</span><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">pwd</span> <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">-P</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">)</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">)</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span></span>
<span id="cb7-87">  <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">branch_name</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"local"</span></span>
<span id="cb7-88"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">fi</span></span>
<span id="cb7-89"><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">date_dir</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$(</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">date</span> +%Y-%m-%d<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">)</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">-</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">${branch_name}</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span></span>
<span id="cb7-90"><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">TARGET_DIR</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">${BASE_DIR}</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">/</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">${project_owner}</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">-</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">${project_name}</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">/</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">${date_dir}</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">/</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">${DIR}</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span></span>
<span id="cb7-91"></span>
<span id="cb7-92"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mkdir</span> <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">-p</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$TARGET_DIR</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span></span>
<span id="cb7-93"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># BSD mktemp requires XXXXXX at the end of the template (no suffix allowed)</span></span>
<span id="cb7-94"><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">TEMP_PATH</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$(</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mktemp</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">${TARGET_DIR}</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">/</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">${LABEL}</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">-XXXXXX"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">)</span></span>
<span id="cb7-95"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">trap</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'rm -f "$TEMP_PATH"'</span> EXIT</span>
<span id="cb7-96"><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">FILE_PATH</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">${TEMP_PATH}</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">.md"</span></span>
<span id="cb7-97"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mv</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$TEMP_PATH</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$FILE_PATH</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span></span>
<span id="cb7-98"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">trap</span> <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">-</span> EXIT</span>
<span id="cb7-99"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">echo</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$FILE_PATH</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span></span>
<span id="cb7-100"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">echo</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Created: </span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$FILE_PATH</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;&amp;</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span></span></code></pre></div></div>
</div>
</section>
<section id="aiエージェントとの-integration" class="level2">
<h2 class="anchored" data-anchor-id="aiエージェントとの-integration">5. AIエージェントとの Integration</h2>
<section id="claude.md-agents.md-での定義" class="level3">
<h3 class="anchored" data-anchor-id="claude.md-agents.md-での定義">5.1. CLAUDE.md / AGENTS.md での定義</h3>
<p>私の環境では CLAUDE.md / AGENTS.md に以下を書いています。</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb8" style="background: #f1f3f5;"><pre class="sourceCode markdown code-with-copy"><code class="sourceCode markdown"><span id="cb8-1"><span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">- </span>Create working files (not tracked by git) with <span class="in" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">`mkmd`</span> (<span class="in" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">`mkmd --help`</span>)</span>
<span id="cb8-2"><span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">- </span>Common dir/label combinations:</span>
<span id="cb8-3"></span>
<span id="cb8-4">    | --dir     | --label                          |</span>
<span id="cb8-5">    | --------- | -------------------------------- |</span>
<span id="cb8-6">    | draft     | <span class="in" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">`${topic}`</span>                       |</span>
<span id="cb8-7">    | research  | <span class="in" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">`${feature}-investigation`</span>       |</span>
<span id="cb8-8">    | plans     | plan                             |</span>
<span id="cb8-9">    | reviews   | completion                       |</span>
<span id="cb8-10">    | tmp       | <span class="in" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">`${purpose}`</span>                     |</span></code></pre></div></div>
<p>これだけ書いておけばエージェントは <code>mkmd --help</code> で使い方を確認し、適切な <code>--dir</code> / <code>--label</code> を選んでくれます。各スキルに個別の使用例を書く必要はありません。</p>
</section>
<section id="pretooluse-hook-との連携" class="level3">
<h3 class="anchored" data-anchor-id="pretooluse-hook-との連携">5.2. PreToolUse hook との連携</h3>
<p>Claude Code の PreToolUse hook でファイル書き込みを制御している場合、<code>mkmd</code> の出力先を許可リストに追加する必要があります。</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb9" style="background: #f1f3f5;"><pre class="sourceCode bash code-with-copy"><code class="sourceCode bash"><span id="cb9-1"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">elif</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">[[</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">-n</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$FILE_PATH</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">&amp;&amp;</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$FILE_PATH</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$HOME</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">/.local/state/mkmd/"</span><span class="pp" style="color: #AD0000;
background-color: null;
font-style: inherit;">*</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">]];</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">then</span></span>
<span id="cb9-2">  <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">:</span> <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Allow writes to mkmd state directory</span></span></code></pre></div></div>
</section>
<section id="スクリプト内での利用例" class="level3">
<h3 class="anchored" data-anchor-id="スクリプト内での利用例">5.3. スクリプト内での利用例</h3>
<p>他のスクリプトから呼び出す場合、stdout にはファイルパスだけが出力されるため、コマンド置換で受け取れます。</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb10" style="background: #f1f3f5;"><pre class="sourceCode bash code-with-copy"><code class="sourceCode bash"><span id="cb10-1"><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">FILE</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$(</span><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">mkmd</span> <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">--dir</span> tmp <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">--label</span> compact-save<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">)</span></span>
<span id="cb10-2"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">echo</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"# Context Save"</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$FILE</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span></span></code></pre></div></div>
<p><code>Created: ...</code> のメッセージは stderr に出力されるため、stdout のパスと混ざりません。</p>
</section>
</section>
<section id="まとめ" class="level2">
<h2 class="anchored" data-anchor-id="まとめ">6. まとめ</h2>
<p>AIエージェントの作業ファイル管理は地味ですが、散らかると生産性に響きます。</p>
<p><code>mktemp</code> を薄く wrap して「プロジェクト/日付/用途」の構造を自動付与するだけで、以下が手に入ります。</p>
<ul>
<li><code>git status</code> が常にクリーン</li>
<li>作業ファイルがプロジェクト/日付/ブランチで自動整理される</li>
<li>エージェントが自律的にファイルを作り、人間がパスを気にする必要がない</li>
<li>不要になったらディレクトリごと消せる</li>
</ul>
<p>AIエージェントに作業ファイルの置き場所を教えるのに苦労している方は、試してみてください。</p>


<div class="social-share"><a href="https://twitter.com/share?url=https%3A%2F%2Fi9wa4.github.io%2Fblog%2F2026-03-22-mkmd-mktemp-wrapper-for-ai-agents.html&amp;text=AI%E3%81%8C%E3%83%89%E3%82%AD%E3%83%A5%E3%83%A1%E3%83%B3%E3%83%88%E3%82%92%E6%9B%B8%E3%81%8D%E6%95%A3%E3%82%89%E3%81%8B%E3%81%95%E3%81%AA%E3%81%84%E3%81%9F%E3%82%81%E3%81%AE%20mkmd%20%E3%82%B9%E3%82%AF%E3%83%AA%E3%83%97%E3%83%88%E3%81%AE%E7%B4%B9%E4%BB%8B%20%E2%80%93%20uma-chan%E2%80%99s%20page" target="_blank" class="twitter"><i class="bi bi-twitter-x"></i></a><a href="https://bsky.app/intent/compose?text=AI%E3%81%8C%E3%83%89%E3%82%AD%E3%83%A5%E3%83%A1%E3%83%B3%E3%83%88%E3%82%92%E6%9B%B8%E3%81%8D%E6%95%A3%E3%82%89%E3%81%8B%E3%81%95%E3%81%AA%E3%81%84%E3%81%9F%E3%82%81%E3%81%AE%20mkmd%20%E3%82%B9%E3%82%AF%E3%83%AA%E3%83%97%E3%83%88%E3%81%AE%E7%B4%B9%E4%BB%8B%20%E2%80%93%20uma-chan%E2%80%99s%20page%20https%3A%2F%2Fi9wa4.github.io%2Fblog%2F2026-03-22-mkmd-mktemp-wrapper-for-ai-agents.html" target="_blank" class="bsky"><i class="bi bi-bluesky"></i></a><a href="https://www.linkedin.com/shareArticle?url=https%3A%2F%2Fi9wa4.github.io%2Fblog%2F2026-03-22-mkmd-mktemp-wrapper-for-ai-agents.html&amp;title=AI%E3%81%8C%E3%83%89%E3%82%AD%E3%83%A5%E3%83%A1%E3%83%B3%E3%83%88%E3%82%92%E6%9B%B8%E3%81%8D%E6%95%A3%E3%82%89%E3%81%8B%E3%81%95%E3%81%AA%E3%81%84%E3%81%9F%E3%82%81%E3%81%AE%20mkmd%20%E3%82%B9%E3%82%AF%E3%83%AA%E3%83%97%E3%83%88%E3%81%AE%E7%B4%B9%E4%BB%8B%20%E2%80%93%20uma-chan%E2%80%99s%20page" target="_blank" class="linkedin"><i class="bi bi-linkedin"></i></a></div>
</section>

 ]]></description>
  <category>blog</category>
  <category>tech-ai</category>
  <guid>https://i9wa4.github.io/blog/2026-03-22-mkmd-mktemp-wrapper-for-ai-agents.html</guid>
  <pubDate>Sun, 22 Mar 2026 14:55:00 GMT</pubDate>
  <media:content url="https://i9wa4.github.io/assets/common/icon_hhkb3_large.jpg" medium="image" type="image/jpeg"/>
</item>
<item>
  <title>Stop AI from Scattering Docs: Introducing mkmd</title>
  <dc:creator>uma-chan </dc:creator>
  <link>https://i9wa4.github.io/en/blog/2026-03-22-mkmd-mktemp-wrapper-for-ai-agents.html</link>
  <description><![CDATA[ 





<section id="the-problem-ai-agent-work-files-are-a-mess" class="level2">
<h2 class="anchored" data-anchor-id="the-problem-ai-agent-work-files-are-a-mess">1. The Problem: AI Agent Work Files Are a Mess</h2>
<p>If you use Claude Code or Codex CLI on a daily basis, you end up with a pile of temporary Markdown files — investigation notes, plans, review results — that only matter during a session.</p>
<p>Creating them inside the repository means <code>.gitignore</code> headaches. Putting them in <code>/tmp/</code> means they vanish on reboot. And coming up with a path manually every time is just inefficient.</p>
<p>What I wanted was a tool that checks all these boxes:</p>
<ul>
<li>Does not pollute the git repository</li>
<li>Automatically organized by project</li>
<li>Sessions distinguished by date and branch</li>
<li>No filename collisions</li>
<li>One command to create a file</li>
</ul>
</section>
<section id="how-it-helps" class="level2">
<h2 class="anchored" data-anchor-id="how-it-helps">2. How It Helps</h2>
<section id="easy-to-find-later" class="level3">
<h3 class="anchored" data-anchor-id="easy-to-find-later">2.1. Easy to Find Later</h3>
<p>Work files land under <code>~/.local/state/mkmd/</code>, organized by project, date, and branch. “Where did I put that investigation?” is solved with a single <code>ls</code>.</p>
<pre class="text"><code>~/.local/state/mkmd/
├── i9wa4-dotfiles/
│   └── 2026-03-22-main/
│       ├── research/
│       │   └── nix-investigation-aB3xKq.md
│       └── plans/
│           └── plan-Xk9mZw.md
├── i9wa4-i9wa4.github.io/
│   └── 2026-03-22-feat-auth/
│       └── draft/
│           └── design-doc-pQ7rLs.md
└── mycompany-api/
    └── 2026-03-21-issue-42/
        └── reviews/
            └── completion-nW2vHj.md</code></pre>
<p>The directory name tells you which repository, which date, and which branch. Even if you juggle multiple issues on the same day, nothing gets mixed up.</p>
</section>
<section id="keeps-the-repository-clean" class="level3">
<h3 class="anchored" data-anchor-id="keeps-the-repository-clean">2.2. Keeps the Repository Clean</h3>
<p>Output goes to <code>$XDG_STATE_HOME</code> (defaults to <code>~/.local/state</code>), so the git repository is never touched. No need to add anything to <code>.gitignore</code> — your repo stays clean at all times.</p>
</section>
<section id="ai-agents-use-it-autonomously" class="level3">
<h3 class="anchored" data-anchor-id="ai-agents-use-it-autonomously">2.3. AI Agents Use It Autonomously</h3>
<p>Just add one line to your CLAUDE.md / AGENTS.md and agents will create files at the right place during research, planning, and review phases.</p>
<p>The agent runs something like:</p>
<pre class="console"><code>mkmd --dir research --label api-investigation</code></pre>
<p>writes the results to that file, and references it in subsequent tasks.</p>
</section>
<section id="easy-to-clean-up" class="level3">
<h3 class="anchored" data-anchor-id="easy-to-clean-up">2.4. Easy to Clean Up</h3>
<p>When files are no longer needed, delete an entire date directory:</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb3" style="background: #f1f3f5;"><pre class="sourceCode bash code-with-copy"><code class="sourceCode bash"><span id="cb3-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rm</span> <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">-rf</span> ~/.local/state/mkmd/i9wa4-dotfiles/2026-03-20-<span class="pp" style="color: #AD0000;
background-color: null;
font-style: inherit;">*</span></span></code></pre></div></div>
<p>Deleting by project is just as easy. Nothing breaks even if you wipe everything.</p>
</section>
</section>
<section id="mkmd-a-markdown-wrapper-for-mktemp" class="level2">
<h2 class="anchored" data-anchor-id="mkmd-a-markdown-wrapper-for-mktemp">3. mkmd: A Markdown Wrapper for mktemp</h2>
<p><code>mktemp</code> is the standard Unix command for atomically creating temporary files.</p>
<p><code>mkmd</code> is a thin wrapper around it.</p>
<pre class="text"><code>$ mkmd --dir research --label api-investigation
~/.local/state/mkmd/i9wa4-dotfiles/2026-03-22-main/research/api-investigation-xEZZqX.md</code></pre>
<p>The generated path follows this structure:</p>
<pre class="text"><code>$MKMD_BASE_DIR/&lt;owner&gt;-&lt;repo&gt;/YYYY-MM-DD-&lt;branch&gt;/&lt;DIR&gt;/&lt;LABEL&gt;-&lt;XXXXXX&gt;.md</code></pre>
<table class="caption-top table">
<colgroup>
<col style="width: 22%">
<col style="width: 77%">
</colgroup>
<thead>
<tr class="header">
<th>Segment</th>
<th>How It Is Determined</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td><code>MKMD_BASE_DIR</code></td>
<td>Environment variable (default: <code>$XDG_STATE_HOME/mkmd</code>)</td>
</tr>
<tr class="even">
<td><code>owner-repo</code></td>
<td>Extracted from <code>git remote get-url origin</code></td>
</tr>
<tr class="odd">
<td><code>YYYY-MM-DD</code></td>
<td>Date of execution</td>
</tr>
<tr class="even">
<td><code>branch</code></td>
<td><code>git rev-parse --abbrev-ref HEAD</code></td>
</tr>
<tr class="odd">
<td><code>DIR</code></td>
<td><code>--dir</code> argument</td>
</tr>
<tr class="even">
<td><code>LABEL-XXXXXX</code></td>
<td><code>--label</code> argument + random suffix from <code>mktemp</code></td>
</tr>
</tbody>
</table>
<p>When run outside a git repository, it falls back to <code>local-&lt;dirname&gt;/...-local/</code>.</p>
</section>
<section id="full-script" class="level2">
<h2 class="anchored" data-anchor-id="full-script">4. Full Script</h2>
<p>Place it in a directory on your PATH and make it executable.</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb6" style="background: #f1f3f5;"><pre class="sourceCode bash code-with-copy"><code class="sourceCode bash"><span id="cb6-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">chmod</span> +x mkmd</span></code></pre></div></div>
<div class="code-with-filename">
<div class="code-with-filename-file">
<pre><strong>mkmd</strong></pre>
</div>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb7" data-filename="mkmd" style="background: #f1f3f5;"><pre class="sourceCode bash code-with-copy"><code class="sourceCode bash"><span id="cb7-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#!/usr/bin/env bash</span></span>
<span id="cb7-2"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">set</span> <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">-o</span> errexit</span>
<span id="cb7-3"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">set</span> <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">-o</span> nounset</span>
<span id="cb7-4"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">set</span> <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">-o</span> pipefail</span>
<span id="cb7-5"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">set</span> <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">-o</span> posix</span>
<span id="cb7-6"></span>
<span id="cb7-7"><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">BASE_DIR</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">${MKMD_BASE_DIR</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:-</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">${XDG_STATE_HOME</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:-</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$HOME</span>/.local/state<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">}</span>/mkmd<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">}</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span></span>
<span id="cb7-8"></span>
<span id="cb7-9"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print_usage()</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">{</span></span>
<span id="cb7-10">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;&lt;EOF</span></span>
<span id="cb7-11"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">Usage:</span></span>
<span id="cb7-12"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">  mkmd --dir DIR --label LABEL</span></span>
<span id="cb7-13"></span>
<span id="cb7-14"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">mktemp wrapper that creates a markdown working file.</span></span>
<span id="cb7-15"></span>
<span id="cb7-16"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">Creates:</span></span>
<span id="cb7-17"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">  </span><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">\$</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">MKMD_BASE_DIR/&lt;owner&gt;-&lt;repo&gt;/YYYY-MM-DD-&lt;branch&gt;/&lt;DIR&gt;/&lt;LABEL&gt;-&lt;XXXXXX&gt;.md</span></span>
<span id="cb7-18"></span>
<span id="cb7-19"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">  Base directory: </span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">${BASE_DIR}</span></span>
<span id="cb7-20"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">  Works in git repos (uses owner/repo from remote URL) and outside git (uses "local"/dirname).</span></span>
<span id="cb7-21"></span>
<span id="cb7-22"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">Environment:</span></span>
<span id="cb7-23"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">  MKMD_BASE_DIR  Override base directory (default: </span><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">\$</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">XDG_STATE_HOME/mkmd)</span></span>
<span id="cb7-24"></span>
<span id="cb7-25"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">Options:</span></span>
<span id="cb7-26"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">  --dir DIR      Directory name under the daily session</span></span>
<span id="cb7-27"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">  --label LABEL  File label included in the filename</span></span>
<span id="cb7-28"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">  -h, --help     Show this help and exit</span></span>
<span id="cb7-29"><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">EOF</span></span>
<span id="cb7-30"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">}</span></span>
<span id="cb7-31"></span>
<span id="cb7-32"><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">LABEL</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span></span>
<span id="cb7-33"><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">DIR</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span></span>
<span id="cb7-34"></span>
<span id="cb7-35"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Parse arguments</span></span>
<span id="cb7-36"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">while</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">[[</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$#</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">-gt</span> 0 <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">]];</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">do</span></span>
<span id="cb7-37">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">case</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$1</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span></span>
<span id="cb7-38">  <span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">-h</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">|</span> <span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">--help</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">)</span></span>
<span id="cb7-39">    <span class="ex" style="color: null;
background-color: null;
font-style: inherit;">print_usage</span></span>
<span id="cb7-40">    <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">exit</span> 0</span>
<span id="cb7-41">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">;;</span></span>
<span id="cb7-42">  <span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">--dir</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">)</span></span>
<span id="cb7-43">    <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">DIR</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$2</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span></span>
<span id="cb7-44">    <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">shift</span> 2</span>
<span id="cb7-45">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">;;</span></span>
<span id="cb7-46">  <span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">--label</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">)</span></span>
<span id="cb7-47">    <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">LABEL</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$2</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span></span>
<span id="cb7-48">    <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">shift</span> 2</span>
<span id="cb7-49">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">;;</span></span>
<span id="cb7-50">  <span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">-</span><span class="pp" style="color: #AD0000;
background-color: null;
font-style: inherit;">*</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">)</span></span>
<span id="cb7-51">    <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">echo</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Unknown option: </span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$1</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;&amp;</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span></span>
<span id="cb7-52">    <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">exit</span> 1</span>
<span id="cb7-53">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">;;</span></span>
<span id="cb7-54">  <span class="pp" style="color: #AD0000;
background-color: null;
font-style: inherit;">*</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">)</span></span>
<span id="cb7-55">    <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">echo</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Error: Unknown argument: </span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$1</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;&amp;</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span></span>
<span id="cb7-56">    <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">exit</span> 1</span>
<span id="cb7-57">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">;;</span></span>
<span id="cb7-58">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">esac</span></span>
<span id="cb7-59"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">done</span></span>
<span id="cb7-60"></span>
<span id="cb7-61"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Validate DIR and LABEL</span></span>
<span id="cb7-62"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">[[</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">-z</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$DIR</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">||</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">-z</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$LABEL</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">]];</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">then</span></span>
<span id="cb7-63">  <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">echo</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Error: --dir and --label are required"</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;&amp;</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span></span>
<span id="cb7-64">  <span class="ex" style="color: null;
background-color: null;
font-style: inherit;">print_usage</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;&amp;</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span></span>
<span id="cb7-65">  <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">exit</span> 1</span>
<span id="cb7-66"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">fi</span></span>
<span id="cb7-67"></span>
<span id="cb7-68"><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">repo_root</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$(</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">git</span> rev-parse <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">--show-toplevel</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span>/dev/null <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">||</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">true</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">)</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span></span>
<span id="cb7-69"></span>
<span id="cb7-70"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">[[</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">-n</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$repo_root</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">]];</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">then</span></span>
<span id="cb7-71">  <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">remote_url</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$(</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">git</span> remote get-url origin <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span>/dev/null <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">||</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">true</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">)</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span></span>
<span id="cb7-72">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">[[</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">-n</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$remote_url</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">]];</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">then</span></span>
<span id="cb7-73">    <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Extract owner/repo from remote URL (handles both SSH and HTTPS)</span></span>
<span id="cb7-74">    <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">remote_url</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">${remote_url</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%</span>.git<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">}</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span></span>
<span id="cb7-75">    <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">project_name</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">${remote_url</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">##</span><span class="pp" style="color: #AD0000;
background-color: null;
font-style: inherit;">*</span>/<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">}</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span></span>
<span id="cb7-76">    <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">remote_url</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">${remote_url</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%</span>/<span class="pp" style="color: #AD0000;
background-color: null;
font-style: inherit;">*</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">}</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span></span>
<span id="cb7-77">    <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">project_owner</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">${remote_url</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">##</span><span class="pp" style="color: #AD0000;
background-color: null;
font-style: inherit;">*</span>[:/]<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">}</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span></span>
<span id="cb7-78">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span></span>
<span id="cb7-79">    <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">project_owner</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"local"</span></span>
<span id="cb7-80">    <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">project_name</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$(</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">basename</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$repo_root</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">)</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span></span>
<span id="cb7-81">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">fi</span></span>
<span id="cb7-82">  <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">branch_name</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$(</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">git</span> rev-parse <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">--abbrev-ref</span> HEAD <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span>/dev/null <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">||</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">echo</span> unknown<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">)</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span></span>
<span id="cb7-83">  <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">branch_name</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">${branch_name</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">//</span><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">\/</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span>-<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">}</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span></span>
<span id="cb7-84"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span></span>
<span id="cb7-85">  <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">project_owner</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"local"</span></span>
<span id="cb7-86">  <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">project_name</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$(</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">basename</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$(</span><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">pwd</span> <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">-P</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">)</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">)</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span></span>
<span id="cb7-87">  <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">branch_name</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"local"</span></span>
<span id="cb7-88"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">fi</span></span>
<span id="cb7-89"><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">date_dir</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$(</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">date</span> +%Y-%m-%d<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">)</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">-</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">${branch_name}</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span></span>
<span id="cb7-90"><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">TARGET_DIR</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">${BASE_DIR}</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">/</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">${project_owner}</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">-</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">${project_name}</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">/</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">${date_dir}</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">/</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">${DIR}</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span></span>
<span id="cb7-91"></span>
<span id="cb7-92"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mkdir</span> <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">-p</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$TARGET_DIR</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span></span>
<span id="cb7-93"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># BSD mktemp requires XXXXXX at the end of the template (no suffix allowed)</span></span>
<span id="cb7-94"><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">TEMP_PATH</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$(</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mktemp</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">${TARGET_DIR}</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">/</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">${LABEL}</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">-XXXXXX"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">)</span></span>
<span id="cb7-95"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">trap</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'rm -f "$TEMP_PATH"'</span> EXIT</span>
<span id="cb7-96"><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">FILE_PATH</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">${TEMP_PATH}</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">.md"</span></span>
<span id="cb7-97"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mv</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$TEMP_PATH</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$FILE_PATH</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span></span>
<span id="cb7-98"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">trap</span> <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">-</span> EXIT</span>
<span id="cb7-99"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">echo</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$FILE_PATH</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span></span>
<span id="cb7-100"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">echo</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Created: </span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$FILE_PATH</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;&amp;</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span></span></code></pre></div></div>
</div>
</section>
<section id="integration-with-ai-agents" class="level2">
<h2 class="anchored" data-anchor-id="integration-with-ai-agents">5. Integration with AI Agents</h2>
<section id="defining-in-claude.md-agents.md" class="level3">
<h3 class="anchored" data-anchor-id="defining-in-claude.md-agents.md">5.1. Defining in CLAUDE.md / AGENTS.md</h3>
<p>In my setup, I include the following in CLAUDE.md / AGENTS.md:</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb8" style="background: #f1f3f5;"><pre class="sourceCode markdown code-with-copy"><code class="sourceCode markdown"><span id="cb8-1"><span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">- </span>Create working files (not tracked by git) with <span class="in" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">`mkmd`</span> (<span class="in" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">`mkmd --help`</span>)</span>
<span id="cb8-2"><span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">- </span>Common dir/label combinations:</span>
<span id="cb8-3"></span>
<span id="cb8-4">    | --dir     | --label                          |</span>
<span id="cb8-5">    | --------- | -------------------------------- |</span>
<span id="cb8-6">    | draft     | <span class="in" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">`${topic}`</span>                       |</span>
<span id="cb8-7">    | research  | <span class="in" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">`${feature}-investigation`</span>       |</span>
<span id="cb8-8">    | plans     | plan                             |</span>
<span id="cb8-9">    | reviews   | completion                       |</span>
<span id="cb8-10">    | tmp       | <span class="in" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">`${purpose}`</span>                     |</span></code></pre></div></div>
<p>This is all you need. The agent checks <code>mkmd --help</code> on its own and picks the right <code>--dir</code> / <code>--label</code>. No need to spell out usage examples in each skill.</p>
</section>
<section id="working-with-pretooluse-hooks" class="level3">
<h3 class="anchored" data-anchor-id="working-with-pretooluse-hooks">5.2. Working with PreToolUse Hooks</h3>
<p>If you use Claude Code’s PreToolUse hooks to control file writes, add <code>mkmd</code>’s output directory to the allow list:</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb9" style="background: #f1f3f5;"><pre class="sourceCode bash code-with-copy"><code class="sourceCode bash"><span id="cb9-1"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">elif</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">[[</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">-n</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$FILE_PATH</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">&amp;&amp;</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$FILE_PATH</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$HOME</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">/.local/state/mkmd/"</span><span class="pp" style="color: #AD0000;
background-color: null;
font-style: inherit;">*</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">]];</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">then</span></span>
<span id="cb9-2">  <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">:</span> <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Allow writes to mkmd state directory</span></span></code></pre></div></div>
</section>
<section id="using-from-other-scripts" class="level3">
<h3 class="anchored" data-anchor-id="using-from-other-scripts">5.3. Using from Other Scripts</h3>
<p>When calling <code>mkmd</code> from another script, stdout contains only the file path, so you can capture it with command substitution:</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb10" style="background: #f1f3f5;"><pre class="sourceCode bash code-with-copy"><code class="sourceCode bash"><span id="cb10-1"><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">FILE</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$(</span><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">mkmd</span> <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">--dir</span> tmp <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">--label</span> compact-save<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">)</span></span>
<span id="cb10-2"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">echo</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"# Context Save"</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$FILE</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span></span></code></pre></div></div>
<p>The <code>Created: ...</code> message goes to stderr, so it never mixes with the path on stdout.</p>
</section>
</section>
<section id="summary" class="level2">
<h2 class="anchored" data-anchor-id="summary">6. Summary</h2>
<p>Managing AI agent work files is unglamorous, but clutter kills productivity.</p>
<p>A thin wrapper around <code>mktemp</code> that automatically applies a “project / date / purpose” structure gives you:</p>
<ul>
<li><code>git status</code> stays clean at all times</li>
<li>Work files automatically organized by project, date, and branch</li>
<li>Agents create files autonomously; humans never have to think about paths</li>
<li>Delete an entire directory when you are done</li>
</ul>
<p>If you have been struggling with where to put AI agent work files, give it a try.</p>


<div class="social-share"><a href="https://twitter.com/share?url=https%3A%2F%2Fi9wa4.github.io%2Fen%2Fblog%2F2026-03-22-mkmd-mktemp-wrapper-for-ai-agents.html&amp;text=Stop%20AI%20from%20Scattering%20Docs%3A%20Introducing%20mkmd%20%E2%80%93%20uma-chan%E2%80%99s%20page" target="_blank" class="twitter"><i class="bi bi-twitter-x"></i></a><a href="https://bsky.app/intent/compose?text=Stop%20AI%20from%20Scattering%20Docs%3A%20Introducing%20mkmd%20%E2%80%93%20uma-chan%E2%80%99s%20page%20https%3A%2F%2Fi9wa4.github.io%2Fen%2Fblog%2F2026-03-22-mkmd-mktemp-wrapper-for-ai-agents.html" target="_blank" class="bsky"><i class="bi bi-bluesky"></i></a><a href="https://www.linkedin.com/shareArticle?url=https%3A%2F%2Fi9wa4.github.io%2Fen%2Fblog%2F2026-03-22-mkmd-mktemp-wrapper-for-ai-agents.html&amp;title=Stop%20AI%20from%20Scattering%20Docs%3A%20Introducing%20mkmd%20%E2%80%93%20uma-chan%E2%80%99s%20page" target="_blank" class="linkedin"><i class="bi bi-linkedin"></i></a></div>
</section>

 ]]></description>
  <category>blog</category>
  <category>tech-ai</category>
  <guid>https://i9wa4.github.io/en/blog/2026-03-22-mkmd-mktemp-wrapper-for-ai-agents.html</guid>
  <pubDate>Sun, 22 Mar 2026 14:55:00 GMT</pubDate>
  <media:content url="https://i9wa4.github.io/assets/common/icon_hhkb3_large.jpg" medium="image" type="image/jpeg"/>
</item>
<item>
  <title>Claude Code と Codex CLI のアップデート情報収集術</title>
  <dc:creator>uma-chan </dc:creator>
  <link>https://i9wa4.github.io/blog/2026-03-21-claude-codex-info-gathering.html</link>
  <description><![CDATA[ 





<section id="はじめに" class="level2">
<h2 class="anchored" data-anchor-id="はじめに">1. はじめに</h2>
<p>Claude Code と Codex CLI は両方ともアップデートが頻繁で、新機能や破壊的変更の追い方にそれぞれコツがあります。</p>
<p>2つのツールで情報源の場所が違い、取得コマンドも異なります。 この記事では「どこにあるか・どう取得するか・どう読むか」を具体的なコマンド付きで示します。</p>
<p>前提条件として <code>gh</code>、<code>jq</code>、および調べたいツール (<code>claude</code> / <code>codex</code>) が必要です。</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb1" style="background: #f1f3f5;"><pre class="sourceCode bash code-with-copy"><code class="sourceCode bash"><span id="cb1-1"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">gh</span> auth status   <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># gh が認証済みであることを確認する</span></span>
<span id="cb1-2"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">jq</span> <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">--version</span>     <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># jq がインストール済みであることを確認する</span></span></code></pre></div></div>
</section>
<section id="claude-code-の情報収集" class="level2">
<h2 class="anchored" data-anchor-id="claude-code-の情報収集">2. Claude Code の情報収集</h2>
<section id="インストール済みバージョンの確認" class="level3">
<h3 class="anchored" data-anchor-id="インストール済みバージョンの確認">2.1. インストール済みバージョンの確認</h3>
<p>まずローカルにインストールされているバージョンを確認します。</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb2" style="background: #f1f3f5;"><pre class="sourceCode bash code-with-copy"><code class="sourceCode bash"><span id="cb2-1"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">claude</span> <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">--version</span></span></code></pre></div></div>
<p>出力例</p>
<pre class="text"><code>2.1.76 (Claude Code)</code></pre>
<p>このバージョン番号を起点にします。 CHANGELOG を読む際はこのバージョン以下の変更のみを対象にします。 ローカルにない新しいバージョンの変更を先取りして読んでも、実際の動作と一致しないためです。</p>
</section>
<section id="changelog-の取得" class="level3">
<h3 class="anchored" data-anchor-id="changelog-の取得">2.2. CHANGELOG の取得</h3>
<p>Claude Code の変更履歴は GitHub リポジトリの <code>CHANGELOG.md</code> にあります。 Contents API に Raw メディアタイプを指定すると、ファイル内容をそのまま取得できます。</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb4" style="background: #f1f3f5;"><pre class="sourceCode bash code-with-copy"><code class="sourceCode bash"><span id="cb4-1"><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">FILE</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$(</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mktemp</span> /tmp/claude-changelog-XXXXXX.md<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">)</span></span>
<span id="cb4-2"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">gh</span> api repos/anthropics/claude-code/contents/CHANGELOG.md <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">\</span></span>
<span id="cb4-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">-H</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Accept: application/vnd.github.raw+json"</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$FILE</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span></span></code></pre></div></div>
</section>
<section id="対象バージョンのセクション確認" class="level3">
<h3 class="anchored" data-anchor-id="対象バージョンのセクション確認">2.3. 対象バージョンのセクション確認</h3>
<p>取得した CHANGELOG を開いて、インストール済みバージョンの <code>## &lt;version&gt;</code> セクションを探します。</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb5" style="background: #f1f3f5;"><pre class="sourceCode bash code-with-copy"><code class="sourceCode bash"><span id="cb5-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">grep</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^## "</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$FILE</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">|</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">head</span> <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">-20</span></span></code></pre></div></div>
<p>各バージョンのセクション見出しが一覧されます。 確認したいバージョンのセクション範囲を絞って読むと効率的です。</p>
<p>変更内容は大まかに次の種別に分かれています。</p>
<table class="caption-top table">
<thead>
<tr class="header">
<th>種別</th>
<th>内容</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td>Added</td>
<td>新機能の追加</td>
</tr>
<tr class="even">
<td>Fixed</td>
<td>バグ修正</td>
</tr>
<tr class="odd">
<td>Improved</td>
<td>既存機能の改善</td>
</tr>
<tr class="even">
<td>Deprecated</td>
<td>将来削除予定の機能</td>
</tr>
</tbody>
</table>
</section>
<section id="破壊的変更の検出" class="level3">
<h3 class="anchored" data-anchor-id="破壊的変更の検出">2.4. 破壊的変更の検出</h3>
<p><code>Deprecated</code>、<code>Removed</code>、<code>Breaking</code>、<code>Changed</code> の語を検索します。</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb6" style="background: #f1f3f5;"><pre class="sourceCode bash code-with-copy"><code class="sourceCode bash"><span id="cb6-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">grep</span> <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">-i</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"deprecated\|removed\|breaking\|changed"</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$FILE</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span></span></code></pre></div></div>
<p>このコマンドは CHANGELOG 全体を対象にするため、インストール済みより新しいバージョンの変更も含まれます。 ヒットした行が自分のバージョン以下のセクションにあるかを確認してから、設定ファイル (<code>~/.claude/settings.json</code>、<code>CLAUDE.md</code> など) への影響を判断してください。</p>
</section>
<section id="仕様の詳細調査" class="level3">
<h3 class="anchored" data-anchor-id="仕様の詳細調査">2.5. 仕様の詳細調査</h3>
<p>ドキュメントに明示されていない動作や設定の詳細を調べたい場合、Claude Code の仕様調査に特化した <code>claude-code-guide</code> スキルが役立ちます。</p>
<p>Claude Code の Agent ツールから Task として呼び出すと、組み込みドキュメントに基づいた回答を返してくれます。</p>
<p>Codex CLI には <code>claude-code-guide</code> に相当する専用スキルが見当たらないため、この調べ方は現時点では Claude Code 側で特に有効です。</p>
</section>
</section>
<section id="codex-cli-の情報収集" class="level2">
<h2 class="anchored" data-anchor-id="codex-cli-の情報収集">3. Codex CLI の情報収集</h2>
<section id="インストール済みバージョンの確認-1" class="level3">
<h3 class="anchored" data-anchor-id="インストール済みバージョンの確認-1">3.1. インストール済みバージョンの確認</h3>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb7" style="background: #f1f3f5;"><pre class="sourceCode bash code-with-copy"><code class="sourceCode bash"><span id="cb7-1"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">codex</span> <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">--version</span></span></code></pre></div></div>
<p>出力例</p>
<pre class="text"><code>codex-cli 0.115.0</code></pre>
<p>Claude Code と同様に、このバージョン以下のリリースを分析対象にします。 ローカルバージョンより新しいリリースの変更内容は参考程度にとどめます。</p>
<p>Codex CLI は <code>CHANGELOG.md</code> ではなく GitHub Releases ページを情報源にしています。 この点が Claude Code と大きく異なります。</p>
</section>
<section id="インストール済みバージョンのリリースノートを取得" class="level3">
<h3 class="anchored" data-anchor-id="インストール済みバージョンのリリースノートを取得">3.2. インストール済みバージョンのリリースノートを取得</h3>
<p>タグを直接指定して取得することで、インストール済みバージョンのリリースノートのみを確実に得られます。</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb9" style="background: #f1f3f5;"><pre class="sourceCode bash code-with-copy"><code class="sourceCode bash"><span id="cb9-1"><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">LOCAL_VERSION</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$(</span><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">codex</span> <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">--version</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">|</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">grep</span> <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">-o</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'[0-9]\+\.[0-9]\+\.[0-9]\+'</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">)</span></span>
<span id="cb9-2"><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">FILE</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$(</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mktemp</span> /tmp/codex-releases-XXXXXX.json<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">)</span></span>
<span id="cb9-3"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">gh</span> api <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"repos/openai/codex/releases/tags/rust-v</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">${LOCAL_VERSION}</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$FILE</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span></span></code></pre></div></div>
<p>タグの形式は <code>rust-v&lt;version&gt;</code> です (例: <code>rust-v0.115.0</code>)。 バージョン番号だけのタグではないので注意が必要です。</p>
</section>
<section id="リリースノートの内容を確認" class="level3">
<h3 class="anchored" data-anchor-id="リリースノートの内容を確認">3.3. リリースノートの内容を確認</h3>
<p>取得した JSON の <code>body</code> フィールドにリリースノートの本文が入っています。</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb10" style="background: #f1f3f5;"><pre class="sourceCode bash code-with-copy"><code class="sourceCode bash"><span id="cb10-1"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">jq</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'{tag_name, body}'</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$FILE</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span></span></code></pre></div></div>
<p>Markdown 形式で書かれているため、そのまま読めます。</p>
</section>
<section id="破壊的変更の検出-1" class="level3">
<h3 class="anchored" data-anchor-id="破壊的変更の検出-1">3.4. 破壊的変更の検出</h3>
<p>リリースノートの本文から影響のある語を検索します。</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb11" style="background: #f1f3f5;"><pre class="sourceCode bash code-with-copy"><code class="sourceCode bash"><span id="cb11-1"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">jq</span> <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">-r</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'.body'</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$FILE</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">|</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">grep</span> <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">-i</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"breaking\|removed\|deprecated"</span></span></code></pre></div></div>
<p>該当行が見つかれば、リリースノートの該当箇所を読んでマイグレーションパスを確認してから、設定ファイル (<code>~/.codex/config.toml</code>、<code>rules/</code> など) への影響を判断します。</p>
</section>
</section>
<section id="まとめ" class="level2">
<h2 class="anchored" data-anchor-id="まとめ">4. まとめ</h2>
<section id="情報収集の比較" class="level3">
<h3 class="anchored" data-anchor-id="情報収集の比較">4.1. 情報収集の比較</h3>
<table class="caption-top table">
<colgroup>
<col style="width: 19%">
<col style="width: 41%">
<col style="width: 38%">
</colgroup>
<thead>
<tr class="header">
<th>項目</th>
<th>Claude Code</th>
<th>Codex CLI</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td>バージョン確認</td>
<td><code>claude --version</code></td>
<td><code>codex --version</code></td>
</tr>
<tr class="even">
<td>情報源</td>
<td>CHANGELOG.md (Contents API Raw)</td>
<td>GitHub Releases API</td>
</tr>
<tr class="odd">
<td>タグ形式</td>
<td><code>## &lt;version&gt;</code></td>
<td><code>rust-v&lt;version&gt;</code></td>
</tr>
<tr class="even">
<td>仕様詳細調査</td>
<td>claude-code-guide サブエージェント</td>
<td>releases 本文 + コード読解</td>
</tr>
</tbody>
</table>
</section>
<section id="スコープガードの習慣" class="level3">
<h3 class="anchored" data-anchor-id="スコープガードの習慣">4.2. スコープガードの習慣</h3>
<p>両ツールとも「ローカルバージョン以下に絞る」という制約を忘れないようにしています。 新しいバージョンの変更を先読みしても、実際の動作と合わなくて混乱するだけです。</p>
</section>
</section>
<section id="スキルとして使う" class="level2">
<h2 class="anchored" data-anchor-id="スキルとして使う">5. スキルとして使う</h2>
<section id="スキルとは" class="level3">
<h3 class="anchored" data-anchor-id="スキルとは">5.1. スキルとは</h3>
<p>Claude Code のスキルは <code>~/.claude/skills/&lt;name&gt;/SKILL.md</code> に置くことで 起動時に自動的に読み込まれます。以下のブロックをコピーして保存するだけで、 <code>/claude-config-optimizer</code>・<code>/codex-config-optimizer</code> コマンドとして呼び出せるようになります。 追加後は Claude Code を再起動して読み込ませてください。</p>
</section>
<section id="references-による蓄積" class="level3">
<h3 class="anchored" data-anchor-id="references-による蓄積">5.2. references/ による蓄積</h3>
<p>各スキルには <code>references/</code> ディレクトリを設けます。 スキルを実行するたびに、確認したバージョン・注目した変更・対応方針を 1 ファイルに追記していきます。</p>
<p>蓄積があると次回の実行時に「前回どこまで確認したか」「見送った項目はどれか」がわかり、アップデート情報のピックアップが楽になります。</p>
<pre class="text"><code>~/.claude/skills/claude-config-optimizer/
  SKILL.md
  references/
    changelog-tracking.md   # 蓄積ファイル (1 ファイルに追記)

~/.claude/skills/codex-config-optimizer/
  SKILL.md
  references/
    release-tracking.md     # 蓄積ファイル (1 ファイルに追記)</code></pre>
</section>
<section id="claude-code-用スキル" class="level3">
<h3 class="anchored" data-anchor-id="claude-code-用スキル">5.3. Claude Code 用スキル</h3>
<p>以下のブロックを <code>~/.claude/skills/claude-config-optimizer/SKILL.md</code> にコピーして保存します。</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb13" style="background: #f1f3f5;"><pre class="sourceCode bash code-with-copy"><code class="sourceCode bash"><span id="cb13-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mkdir</span> <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">-p</span> ~/.claude/skills/claude-config-optimizer/references</span></code></pre></div></div>
<div class="code-with-filename">
<div class="code-with-filename-file">
<pre><strong>~/.claude/skills/claude-config-optimizer/SKILL.md</strong></pre>
</div>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb14" data-filename="~/.claude/skills/claude-config-optimizer/SKILL.md" style="background: #f1f3f5;"><pre class="sourceCode markdown code-with-copy"><code class="sourceCode markdown"><span id="cb14-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">---</span></span>
<span id="cb14-2"><span class="an" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">name:</span><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"> claude-config-optimizer</span></span>
<span id="cb14-3"><span class="an" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">description:</span><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"> |</span></span>
<span id="cb14-4"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">  Claude Code の CHANGELOG をインストール済みバージョンに絞って確認する。</span></span>
<span id="cb14-5"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">  Use when:</span></span>
<span id="cb14-6"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">  - User says "changelog" or "updates" about Claude Code</span></span>
<span id="cb14-7"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">  - Checking for breaking changes before upgrading</span></span>
<span id="cb14-8"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">---</span></span>
<span id="cb14-9"></span>
<span id="cb14-10"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;"># Claude Config Optimizer Skill</span></span>
<span id="cb14-11"></span>
<span id="cb14-12">全ステップを順番に実行し、結果をまとめて報告する。</span>
<span id="cb14-13">途中で確認を求めず、最後まで一気に進める。</span>
<span id="cb14-14">設定ファイルの書き換えは行わない。</span>
<span id="cb14-15"></span>
<span id="cb14-16"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">## 1. インストール済みバージョンを確認する</span></span>
<span id="cb14-17"></span>
<span id="cb14-18"><span class="in" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">```{.bash}</span></span>
<span id="cb14-19"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">claude</span> <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">--version</span></span>
<span id="cb14-20"><span class="in" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">```</span></span>
<span id="cb14-21"></span>
<span id="cb14-22">この番号以下の CHANGELOG セクションのみを分析対象にする。</span>
<span id="cb14-23"></span>
<span id="cb14-24"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">## 2. CHANGELOG を取得する</span></span>
<span id="cb14-25"></span>
<span id="cb14-26"><span class="in" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">```{.bash}</span></span>
<span id="cb14-27"><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">FILE</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$(</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mktemp</span> /tmp/claude-changelog-XXXXXX.md<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">)</span></span>
<span id="cb14-28"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">gh</span> api repos/anthropics/claude-code/contents/CHANGELOG.md <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">\</span></span>
<span id="cb14-29">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">-H</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Accept: application/vnd.github.raw+json"</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$FILE</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span></span>
<span id="cb14-30"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">echo</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Saved to </span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$FILE</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span></span>
<span id="cb14-31"><span class="in" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">```</span></span>
<span id="cb14-32"></span>
<span id="cb14-33"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">## 3. バージョンセクション一覧を確認する</span></span>
<span id="cb14-34"></span>
<span id="cb14-35"><span class="in" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">```{.bash}</span></span>
<span id="cb14-36"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">grep</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^## "</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$FILE</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">|</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">head</span> <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">-20</span></span>
<span id="cb14-37"><span class="in" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">```</span></span>
<span id="cb14-38"></span>
<span id="cb14-39"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">## 4. 破壊的変更を検索する</span></span>
<span id="cb14-40"></span>
<span id="cb14-41"><span class="in" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">```{.bash}</span></span>
<span id="cb14-42"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">grep</span> <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">-i</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"deprecated\|removed\|breaking\|changed"</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$FILE</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span></span>
<span id="cb14-43"><span class="in" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">```</span></span>
<span id="cb14-44"></span>
<span id="cb14-45">インストール済みバージョン以下のセクションのヒットのみを報告する。</span>
<span id="cb14-46"></span>
<span id="cb14-47"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">## 5. 報告をまとめる</span></span>
<span id="cb14-48"></span>
<span id="cb14-49">ステップ 3-4 の結果をもとに、以下を一括で報告する。</span>
<span id="cb14-50"></span>
<span id="cb14-51"><span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">1. </span>アップデート情報の要約 (Added/Fixed/Deprecated)</span>
<span id="cb14-52"><span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">2. </span>設定ファイルへの影響判定と変更提案</span>
<span id="cb14-53"><span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">   - </span><span class="in" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">`~/.claude/settings.json`</span></span>
<span id="cb14-54"><span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">   - </span><span class="in" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">`CLAUDE.md`</span>、<span class="in" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">`rules/`</span>、<span class="in" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">`skills/`</span></span>
<span id="cb14-55"></span>
<span id="cb14-56"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">## 6. 調査結果を references/ に蓄積する</span></span>
<span id="cb14-57"></span>
<span id="cb14-58"><span class="in" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">`references/changelog-tracking.md`</span> に追記する。</span>
<span id="cb14-59">ファイルが存在しなければ新規作成する。</span>
<span id="cb14-60">以下のセクション構成で管理する。</span>
<span id="cb14-61"></span>
<span id="cb14-62"><span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">- </span>Applied: 採用した変更と適用内容</span>
<span id="cb14-63"><span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">- </span>Not Adopting: 見送った項目と理由</span>
<span id="cb14-64"><span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">- </span>Version Notes: バージョンごとの主要変更メモ (日付付き)</span>
<span id="cb14-65"></span>
<span id="cb14-66">既存の記録があれば前回との差分のみ追記する。</span></code></pre></div></div>
</div>
</section>
<section id="codex-cli-用スキル" class="level3">
<h3 class="anchored" data-anchor-id="codex-cli-用スキル">5.4. Codex CLI 用スキル</h3>
<p>以下のブロックを <code>~/.claude/skills/codex-config-optimizer/SKILL.md</code> にコピーして保存します。</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb15" style="background: #f1f3f5;"><pre class="sourceCode bash code-with-copy"><code class="sourceCode bash"><span id="cb15-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mkdir</span> <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">-p</span> ~/.claude/skills/codex-config-optimizer/references</span></code></pre></div></div>
<div class="code-with-filename">
<div class="code-with-filename-file">
<pre><strong>~/.claude/skills/codex-config-optimizer/SKILL.md</strong></pre>
</div>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb16" data-filename="~/.claude/skills/codex-config-optimizer/SKILL.md" style="background: #f1f3f5;"><pre class="sourceCode markdown code-with-copy"><code class="sourceCode markdown"><span id="cb16-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">---</span></span>
<span id="cb16-2"><span class="an" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">name:</span><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"> codex-config-optimizer</span></span>
<span id="cb16-3"><span class="an" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">description:</span><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"> |</span></span>
<span id="cb16-4"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">  インストール済みバージョンの Codex CLI リリースノートを取得して確認する。</span></span>
<span id="cb16-5"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">  Use when:</span></span>
<span id="cb16-6"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">  - User says "codex changelog" or "codex updates"</span></span>
<span id="cb16-7"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">  - Checking for breaking changes in Codex CLI</span></span>
<span id="cb16-8"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">---</span></span>
<span id="cb16-9"></span>
<span id="cb16-10"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;"># Codex Config Optimizer Skill</span></span>
<span id="cb16-11"></span>
<span id="cb16-12">全ステップを順番に実行し、結果をまとめて報告する。</span>
<span id="cb16-13">途中で確認を求めず、最後まで一気に進める。</span>
<span id="cb16-14">設定ファイルの書き換えは行わない。</span>
<span id="cb16-15">タグ形式は <span class="in" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">`rust-v&lt;version&gt;`</span> (例: <span class="in" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">`rust-v0.115.0`</span>)。</span>
<span id="cb16-16"></span>
<span id="cb16-17"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">## 1. インストール済みバージョンを確認する</span></span>
<span id="cb16-18"></span>
<span id="cb16-19"><span class="in" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">```{.bash}</span></span>
<span id="cb16-20"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">codex</span> <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">--version</span></span>
<span id="cb16-21"><span class="in" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">```</span></span>
<span id="cb16-22"></span>
<span id="cb16-23">このバージョン以下のリリースのみを分析対象にする。</span>
<span id="cb16-24"></span>
<span id="cb16-25"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">## 2. リリースノートを取得する</span></span>
<span id="cb16-26"></span>
<span id="cb16-27"><span class="in" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">```{.bash}</span></span>
<span id="cb16-28"><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">LOCAL_VERSION</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$(</span><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">codex</span> <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">--version</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">|</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">grep</span> <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">-o</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'[0-9]\+\.[0-9]\+\.[0-9]\+'</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">)</span></span>
<span id="cb16-29"><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">FILE</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$(</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mktemp</span> /tmp/codex-releases-XXXXXX.json<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">)</span></span>
<span id="cb16-30"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">gh</span> api <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"repos/openai/codex/releases/tags/rust-v</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">${LOCAL_VERSION}</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$FILE</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span></span>
<span id="cb16-31"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">echo</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Saved to </span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$FILE</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span></span>
<span id="cb16-32"><span class="in" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">```</span></span>
<span id="cb16-33"></span>
<span id="cb16-34"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">## 3. 内容を確認する</span></span>
<span id="cb16-35"></span>
<span id="cb16-36"><span class="in" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">```{.bash}</span></span>
<span id="cb16-37"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">jq</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'{tag_name, body}'</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$FILE</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span></span>
<span id="cb16-38"><span class="in" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">```</span></span>
<span id="cb16-39"></span>
<span id="cb16-40"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">## 4. 破壊的変更を検索する</span></span>
<span id="cb16-41"></span>
<span id="cb16-42"><span class="in" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">```{.bash}</span></span>
<span id="cb16-43"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">jq</span> <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">-r</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'.body'</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$FILE</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">|</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">grep</span> <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">-i</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"breaking\|removed\|deprecated"</span></span>
<span id="cb16-44"><span class="in" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">```</span></span>
<span id="cb16-45"></span>
<span id="cb16-46"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">## 5. 報告をまとめる</span></span>
<span id="cb16-47"></span>
<span id="cb16-48">ステップ 3-4 の結果をもとに、以下を一括で報告する。</span>
<span id="cb16-49"></span>
<span id="cb16-50"><span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">1. </span>アップデート情報の要約 (New Features/Bug Fixes/Breaking)</span>
<span id="cb16-51"><span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">2. </span>設定ファイルへの影響判定と変更提案</span>
<span id="cb16-52"><span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">   - </span><span class="in" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">`~/.codex/config.toml`</span></span>
<span id="cb16-53"><span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">   - </span><span class="in" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">`AGENTS.md`</span>、<span class="in" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">`rules/`</span>、<span class="in" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">`skills/`</span></span>
<span id="cb16-54"></span>
<span id="cb16-55"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">## 6. 調査結果を references/ に蓄積する</span></span>
<span id="cb16-56"></span>
<span id="cb16-57"><span class="in" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">`references/release-tracking.md`</span> に追記する。</span>
<span id="cb16-58">ファイルが存在しなければ新規作成する。</span>
<span id="cb16-59">以下のセクション構成で管理する。</span>
<span id="cb16-60"></span>
<span id="cb16-61"><span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">- </span>Applied: 採用した変更と適用内容</span>
<span id="cb16-62"><span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">- </span>Not Adopting: 見送った項目と理由</span>
<span id="cb16-63"><span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">- </span>Version Notes: バージョンごとの主要変更メモ (日付付き)</span>
<span id="cb16-64"></span>
<span id="cb16-65">既存の記録があれば前回との差分のみ追記する。</span></code></pre></div></div>
</div>


<div class="social-share"><a href="https://twitter.com/share?url=https%3A%2F%2Fi9wa4.github.io%2Fblog%2F2026-03-21-claude-codex-info-gathering.html&amp;text=Claude%20Code%20%E3%81%A8%20Codex%20CLI%20%E3%81%AE%E3%82%A2%E3%83%83%E3%83%97%E3%83%87%E3%83%BC%E3%83%88%E6%83%85%E5%A0%B1%E5%8F%8E%E9%9B%86%E8%A1%93%20%E2%80%93%20uma-chan%E2%80%99s%20page" target="_blank" class="twitter"><i class="bi bi-twitter-x"></i></a><a href="https://bsky.app/intent/compose?text=Claude%20Code%20%E3%81%A8%20Codex%20CLI%20%E3%81%AE%E3%82%A2%E3%83%83%E3%83%97%E3%83%87%E3%83%BC%E3%83%88%E6%83%85%E5%A0%B1%E5%8F%8E%E9%9B%86%E8%A1%93%20%E2%80%93%20uma-chan%E2%80%99s%20page%20https%3A%2F%2Fi9wa4.github.io%2Fblog%2F2026-03-21-claude-codex-info-gathering.html" target="_blank" class="bsky"><i class="bi bi-bluesky"></i></a><a href="https://www.linkedin.com/shareArticle?url=https%3A%2F%2Fi9wa4.github.io%2Fblog%2F2026-03-21-claude-codex-info-gathering.html&amp;title=Claude%20Code%20%E3%81%A8%20Codex%20CLI%20%E3%81%AE%E3%82%A2%E3%83%83%E3%83%97%E3%83%87%E3%83%BC%E3%83%88%E6%83%85%E5%A0%B1%E5%8F%8E%E9%9B%86%E8%A1%93%20%E2%80%93%20uma-chan%E2%80%99s%20page" target="_blank" class="linkedin"><i class="bi bi-linkedin"></i></a></div>
</section>
</section>

 ]]></description>
  <category>blog</category>
  <category>tech-ai</category>
  <guid>https://i9wa4.github.io/blog/2026-03-21-claude-codex-info-gathering.html</guid>
  <pubDate>Sat, 21 Mar 2026 11:30:00 GMT</pubDate>
  <media:content url="https://i9wa4.github.io/assets/common/icon_hhkb3_large.jpg" medium="image" type="image/jpeg"/>
</item>
<item>
  <title>Makefile タスク・ランナーの供養</title>
  <dc:creator>uma-chan </dc:creator>
  <link>https://i9wa4.github.io/blog/2026-03-17-makefile-task-runner.html</link>
  <description><![CDATA[ 





<section id="はじめに" class="level2">
<h2 class="anchored" data-anchor-id="はじめに">1. はじめに</h2>
<p>dotfiles リポジトリの <code>bin/Makefile</code> をタスク・ランナーとして活用していました。OS 判定、Vim/Neovim のソースビルド、WSL 設定の管理などをまとめていましたが、Nix へ移行したため不要になりました。削除前に知見を残しておきます。</p>
<p>参考: <a href="https://qiita.com/shakiyam/items/cdd3c11eba978202a628">タスク・ランナーとしてのMake #Makefile - Qiita</a></p>
</section>
<section id="makefile-全体" class="level2">
<h2 class="anchored" data-anchor-id="makefile-全体">2. Makefile 全体</h2>
<div class="code-with-filename">
<div class="code-with-filename-file">
<pre><strong>bin/Makefile</strong></pre>
</div>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb1" data-filename="bin/Makefile" style="background: #f1f3f5;"><pre class="sourceCode makefile code-with-copy"><code class="sourceCode makefile"><span id="cb1-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># [タスク・ランナーとしてのMake \#Makefile - Qiita](https://qiita.com/shakiyam/items/cdd3c11eba978202a628)</span></span>
<span id="cb1-2"><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">SHELL</span> <span class="ch" style="color: #20794D;
background-color: null;
font-style: inherit;">:=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;"> /bin/bash</span></span>
<span id="cb1-3"><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">.SHELLFLAGS</span> <span class="ch" style="color: #20794D;
background-color: null;
font-style: inherit;">:=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;"> -o errexit -o nounset -o pipefail -c</span></span>
<span id="cb1-4"><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">.DEFAULT_GOAL</span> <span class="ch" style="color: #20794D;
background-color: null;
font-style: inherit;">:=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;"> help</span></span>
<span id="cb1-5"><span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">.ONESHELL:</span></span>
<span id="cb1-6"></span>
<span id="cb1-7"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># all targets are phony</span></span>
<span id="cb1-8"><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">PHONY_TARGETS</span> <span class="ch" style="color: #20794D;
background-color: null;
font-style: inherit;">:=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;"> </span><span class="ch" style="color: #20794D;
background-color: null;
font-style: inherit;">$(</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">shell</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;"> grep -E '^[a-zA-Z_-]+:' </span><span class="ch" style="color: #20794D;
background-color: null;
font-style: inherit;">$(</span><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">MAKEFILE_LIST</span><span class="ch" style="color: #20794D;
background-color: null;
font-style: inherit;">)</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;"> | sed 's/://'</span><span class="ch" style="color: #20794D;
background-color: null;
font-style: inherit;">)</span></span>
<span id="cb1-9"><span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">.PHONY:</span><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;"> </span><span class="ch" style="color: #20794D;
background-color: null;
font-style: inherit;">$(</span><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">PHONY_TARGETS</span><span class="ch" style="color: #20794D;
background-color: null;
font-style: inherit;">)</span></span>
<span id="cb1-10"></span>
<span id="cb1-11"><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">help:</span><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">  </span><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">## print this help</span></span>
<span id="cb1-12"><span class="er" style="color: #AD0000;
background-color: null;
font-style: inherit;">    </span><span class="ch" style="color: #20794D;
background-color: null;
font-style: inherit;">@</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">echo </span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'Usage: make [target]'</span></span>
<span id="cb1-13">    <span class="ch" style="color: #20794D;
background-color: null;
font-style: inherit;">@</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">echo </span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">''</span></span>
<span id="cb1-14">    <span class="ch" style="color: #20794D;
background-color: null;
font-style: inherit;">@</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">echo </span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'Targets:'</span></span>
<span id="cb1-15">    <span class="ch" style="color: #20794D;
background-color: null;
font-style: inherit;">@</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">awk </span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "\033[36m%-30s\033[0m %s\n", </span><span class="ch" style="color: #20794D;
background-color: null;
font-style: inherit;">$$</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">1, </span><span class="ch" style="color: #20794D;
background-color: null;
font-style: inherit;">$$</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">2}'</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;"> </span><span class="ch" style="color: #20794D;
background-color: null;
font-style: inherit;">$(</span><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">MAKEFILE_LIST</span><span class="ch" style="color: #20794D;
background-color: null;
font-style: inherit;">)</span></span>
<span id="cb1-16"></span>
<span id="cb1-17"></span>
<span id="cb1-18"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># --------------------------------------</span></span>
<span id="cb1-19"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Global Variables</span></span>
<span id="cb1-20"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#</span></span>
<span id="cb1-21"><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">MF_GITHUB_DIR</span> <span class="ch" style="color: #20794D;
background-color: null;
font-style: inherit;">:=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;"> </span><span class="ch" style="color: #20794D;
background-color: null;
font-style: inherit;">$(</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">shell</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;"> ghq root</span><span class="ch" style="color: #20794D;
background-color: null;
font-style: inherit;">)</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">/github.com</span></span>
<span id="cb1-22"><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">MF_DETECTED_OS</span> <span class="ch" style="color: #20794D;
background-color: null;
font-style: inherit;">:=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;"> </span><span class="ch" style="color: #20794D;
background-color: null;
font-style: inherit;">$(</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">shell</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;"> \</span></span>
<span id="cb1-23"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">    _uname="</span><span class="ch" style="color: #20794D;
background-color: null;
font-style: inherit;">$$</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">(uname -a)"; \</span></span>
<span id="cb1-24"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">    if echo "</span><span class="ch" style="color: #20794D;
background-color: null;
font-style: inherit;">$$</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">{_uname}" | grep -q Darwin; then \</span></span>
<span id="cb1-25"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">        echo "macOS"; \</span></span>
<span id="cb1-26"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">    elif echo "</span><span class="ch" style="color: #20794D;
background-color: null;
font-style: inherit;">$$</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">{_uname}" | grep -q WSL2; then \</span></span>
<span id="cb1-27"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">        echo "WSL2"; \</span></span>
<span id="cb1-28"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">    elif echo "</span><span class="ch" style="color: #20794D;
background-color: null;
font-style: inherit;">$$</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">{_uname}" | grep -q Ubuntu; then \</span></span>
<span id="cb1-29"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">        echo "Ubuntu"; \</span></span>
<span id="cb1-30"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">    else \</span></span>
<span id="cb1-31"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">        echo "Unknown"; \</span></span>
<span id="cb1-32"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">    fi</span><span class="ch" style="color: #20794D;
background-color: null;
font-style: inherit;">)</span></span>
<span id="cb1-33"></span>
<span id="cb1-34"><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">MF_WIN_UTIL_DIR</span> <span class="ch" style="color: #20794D;
background-color: null;
font-style: inherit;">:=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;"> /mnt/c/work/util</span></span>
<span id="cb1-35"></span>
<span id="cb1-36"></span>
<span id="cb1-37"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># nvim-build:  ## build Neovim from source</span></span>
<span id="cb1-38"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#   ghq get -p neovim/neovim</span></span>
<span id="cb1-39"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#   cd $(MF_GITHUB_DIR)/neovim/neovim &amp;&amp; \</span></span>
<span id="cb1-40"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#   make distclean || true &amp;&amp; \</span></span>
<span id="cb1-41"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#   make CMAKE_BUILD_TYPE=Release CMAKE_INSTALL_PREFIX="$${HOME}"/.local &amp;&amp; \</span></span>
<span id="cb1-42"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#   make install &amp;&amp; \</span></span>
<span id="cb1-43"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#   rm -rf build</span></span>
<span id="cb1-44"></span>
<span id="cb1-45"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># vim-build:  ## build Vim from source</span></span>
<span id="cb1-46"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#   ghq get -p vim/vim</span></span>
<span id="cb1-47"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># ifeq ($(MF_DETECTED_OS),macOS)</span></span>
<span id="cb1-48"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#   cd $(MF_GITHUB_DIR)/vim/vim/src &amp;&amp; \</span></span>
<span id="cb1-49"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#   make distclean || true &amp;&amp; \</span></span>
<span id="cb1-50"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#   ./configure \</span></span>
<span id="cb1-51"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#       --disable-gui \</span></span>
<span id="cb1-52"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#       --enable-clipboard \</span></span>
<span id="cb1-53"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#       --enable-darwin \</span></span>
<span id="cb1-54"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#       --enable-fail-if-missing \</span></span>
<span id="cb1-55"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#       --enable-multibyte \</span></span>
<span id="cb1-56"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#       --prefix="$${HOME}"/.local \</span></span>
<span id="cb1-57"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#       --with-features=huge \</span></span>
<span id="cb1-58"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#       --without-wayland &amp;&amp; \</span></span>
<span id="cb1-59"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#   make &amp;&amp; \</span></span>
<span id="cb1-60"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#   make install</span></span>
<span id="cb1-61"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># else</span></span>
<span id="cb1-62"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#   cd $(MF_GITHUB_DIR)/vim/vim/src &amp;&amp; \</span></span>
<span id="cb1-63"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#   make distclean || true &amp;&amp; \</span></span>
<span id="cb1-64"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#   ./configure \</span></span>
<span id="cb1-65"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#       --disable-gui \</span></span>
<span id="cb1-66"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#       --enable-clipboard \</span></span>
<span id="cb1-67"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#       --enable-fail-if-missing \</span></span>
<span id="cb1-68"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#       --enable-multibyte \</span></span>
<span id="cb1-69"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#       --prefix="$${HOME}"/.local \</span></span>
<span id="cb1-70"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#       --with-features=huge \</span></span>
<span id="cb1-71"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#       --without-x \</span></span>
<span id="cb1-72"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#       --without-wayland &amp;&amp; \</span></span>
<span id="cb1-73"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#   make &amp;&amp; \</span></span>
<span id="cb1-74"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#   make install</span></span>
<span id="cb1-75"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># endif</span></span>
<span id="cb1-76"></span>
<span id="cb1-77"></span>
<span id="cb1-78"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># --------------------------------------</span></span>
<span id="cb1-79"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Ubuntu Tasks</span></span>
<span id="cb1-80"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#</span></span>
<span id="cb1-81"><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">ubuntu-apt:</span><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">  </span><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">## update and upgrade packages in Ubuntu</span></span>
<span id="cb1-82"><span class="er" style="color: #AD0000;
background-color: null;
font-style: inherit;">    </span>sudo apt-get update &amp;&amp; sudo apt-get upgrade -y</span>
<span id="cb1-83"></span>
<span id="cb1-84"></span>
<span id="cb1-85"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># --------------------------------------</span></span>
<span id="cb1-86"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># WSL Tasks (Windows integration)</span></span>
<span id="cb1-87"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#</span></span>
<span id="cb1-88"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">define</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">MF_WSLCONF_IN_WSL</span></span>
<span id="cb1-89"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">[boot]</span></span>
<span id="cb1-90"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">systemd=true</span></span>
<span id="cb1-91"></span>
<span id="cb1-92"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">[interop]</span></span>
<span id="cb1-93"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">appendWindowsPath=true</span></span>
<span id="cb1-94"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">endef</span></span>
<span id="cb1-95"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">export</span><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;"> MF_WSLCONF_IN_WSL</span></span>
<span id="cb1-96"></span>
<span id="cb1-97"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">define</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">MF_WSLCONFIG_IN_WINDOWS</span></span>
<span id="cb1-98"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">[wsl2]</span></span>
<span id="cb1-99"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">localhostForwarding=true</span></span>
<span id="cb1-100"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">processors=2</span></span>
<span id="cb1-101"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">swap=0</span></span>
<span id="cb1-102"></span>
<span id="cb1-103"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">[experimental]</span></span>
<span id="cb1-104"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">autoMemoryReclaim=gradual</span></span>
<span id="cb1-105"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">endef</span></span>
<span id="cb1-106"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">export</span><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;"> MF_WSLCONFIG_IN_WINDOWS</span></span>
<span id="cb1-107"></span>
<span id="cb1-108"><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">win-copy:</span><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">  </span><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">## copy config files for Windows (WSL only)</span></span>
<span id="cb1-109">    <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># WSL2</span></span>
<span id="cb1-110">    echo <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="ch" style="color: #20794D;
background-color: null;
font-style: inherit;">$$</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">{MF_WSLCONF_IN_WSL}"</span> | sudo tee /etc/wsl.conf</span>
<span id="cb1-111">    <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Windows</span></span>
<span id="cb1-112">    echo <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="ch" style="color: #20794D;
background-color: null;
font-style: inherit;">$$</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">{MF_WSLCONFIG_IN_WINDOWS}"</span> | \</span>
<span id="cb1-113">        tee <span class="ch" style="color: #20794D;
background-color: null;
font-style: inherit;">$(</span><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">MF_WIN_UTIL_DIR</span><span class="ch" style="color: #20794D;
background-color: null;
font-style: inherit;">)</span>/etc/dot.wslconfig</span>
<span id="cb1-114">    rm -rf <span class="ch" style="color: #20794D;
background-color: null;
font-style: inherit;">$(</span><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">MF_WIN_UTIL_DIR</span><span class="ch" style="color: #20794D;
background-color: null;
font-style: inherit;">)</span></span>
<span id="cb1-115">    cp -rf <span class="ch" style="color: #20794D;
background-color: null;
font-style: inherit;">$(</span><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">MF_GITHUB_DIR</span><span class="ch" style="color: #20794D;
background-color: null;
font-style: inherit;">)</span>/i9wa4/dotfiles/bin <span class="ch" style="color: #20794D;
background-color: null;
font-style: inherit;">$(</span><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">MF_WIN_UTIL_DIR</span><span class="ch" style="color: #20794D;
background-color: null;
font-style: inherit;">)</span></span></code></pre></div></div>
</div>
</section>
<section id="テクニック解説" class="level2">
<h2 class="anchored" data-anchor-id="テクニック解説">3. テクニック解説</h2>
<section id="堅牢なシェル設定" class="level3">
<h3 class="anchored" data-anchor-id="堅牢なシェル設定">3.1. 堅牢なシェル設定</h3>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb2" style="background: #f1f3f5;"><pre class="sourceCode makefile code-with-copy"><code class="sourceCode makefile"><span id="cb2-1"><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">SHELL</span> <span class="ch" style="color: #20794D;
background-color: null;
font-style: inherit;">:=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;"> /bin/bash</span></span>
<span id="cb2-2"><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">.SHELLFLAGS</span> <span class="ch" style="color: #20794D;
background-color: null;
font-style: inherit;">:=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;"> -o errexit -o nounset -o pipefail -c</span></span>
<span id="cb2-3"><span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">.ONESHELL:</span></span></code></pre></div></div>
<table class="caption-top table">
<colgroup>
<col style="width: 31%">
<col style="width: 68%">
</colgroup>
<thead>
<tr class="header">
<th>設定</th>
<th>効果</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td><code>SHELL := /bin/bash</code></td>
<td>デフォルトの <code>/bin/sh</code> ではなく Bash を明示的に使用</td>
</tr>
<tr class="even">
<td><code>-o errexit</code></td>
<td>コマンド失敗時に即座に停止 (<code>set -e</code> 相当)</td>
</tr>
<tr class="odd">
<td><code>-o nounset</code></td>
<td>未定義変数の参照をエラーにする (<code>set -u</code> 相当)</td>
</tr>
<tr class="even">
<td><code>-o pipefail</code></td>
<td>パイプライン中の失敗を検出 (<code>set -o pipefail</code> 相当)</td>
</tr>
<tr class="odd">
<td><code>.ONESHELL:</code></td>
<td>レシピ内の複数行を単一のシェルプロセスで実行</td>
</tr>
</tbody>
</table>
<p><code>.ONESHELL:</code> がないとレシピの各行が別々のシェルで実行されるため、<code>cd</code> した後のコマンドが期待通りに動かないことがあります。</p>
</section>
<section id="自己文書化-help-ターゲット" class="level3">
<h3 class="anchored" data-anchor-id="自己文書化-help-ターゲット">3.2. 自己文書化 help ターゲット</h3>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb3" style="background: #f1f3f5;"><pre class="sourceCode makefile code-with-copy"><code class="sourceCode makefile"><span id="cb3-1"><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">help:</span><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">  </span><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">## print this help</span></span>
<span id="cb3-2"><span class="er" style="color: #AD0000;
background-color: null;
font-style: inherit;">    </span><span class="ch" style="color: #20794D;
background-color: null;
font-style: inherit;">@</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">awk </span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "\033[36m%-30s\033[0m %s\n", </span><span class="ch" style="color: #20794D;
background-color: null;
font-style: inherit;">$$</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">1, </span><span class="ch" style="color: #20794D;
background-color: null;
font-style: inherit;">$$</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">2}'</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;"> </span><span class="ch" style="color: #20794D;
background-color: null;
font-style: inherit;">$(</span><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">MAKEFILE_LIST</span><span class="ch" style="color: #20794D;
background-color: null;
font-style: inherit;">)</span></span></code></pre></div></div>
<p>ターゲット定義の行に <code>## コメント</code> を書くだけで <code>make help</code> の出力に自動的に表示されます。<code>.DEFAULT_GOAL := help</code> と組み合わせることで、引数なしの <code>make</code> で使い方が表示されます。</p>
</section>
<section id="動的-.phony-定義" class="level3">
<h3 class="anchored" data-anchor-id="動的-.phony-定義">3.3. 動的 .PHONY 定義</h3>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb4" style="background: #f1f3f5;"><pre class="sourceCode makefile code-with-copy"><code class="sourceCode makefile"><span id="cb4-1"><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">PHONY_TARGETS</span> <span class="ch" style="color: #20794D;
background-color: null;
font-style: inherit;">:=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;"> </span><span class="ch" style="color: #20794D;
background-color: null;
font-style: inherit;">$(</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">shell</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;"> grep -E '^[a-zA-Z_-]+:' </span><span class="ch" style="color: #20794D;
background-color: null;
font-style: inherit;">$(</span><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">MAKEFILE_LIST</span><span class="ch" style="color: #20794D;
background-color: null;
font-style: inherit;">)</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;"> | sed 's/://'</span><span class="ch" style="color: #20794D;
background-color: null;
font-style: inherit;">)</span></span>
<span id="cb4-2"><span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">.PHONY:</span><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;"> </span><span class="ch" style="color: #20794D;
background-color: null;
font-style: inherit;">$(</span><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">PHONY_TARGETS</span><span class="ch" style="color: #20794D;
background-color: null;
font-style: inherit;">)</span></span></code></pre></div></div>
<p>ターゲット名を正規表現で抽出して全ターゲットを <code>.PHONY</code> にしています。タスク・ランナーとしての Makefile ではファイルを生成するターゲットがないため、全ターゲットを <code>.PHONY</code> にするのが合理的です。</p>
</section>
<section id="os-判定" class="level3">
<h3 class="anchored" data-anchor-id="os-判定">3.4. OS 判定</h3>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb5" style="background: #f1f3f5;"><pre class="sourceCode makefile code-with-copy"><code class="sourceCode makefile"><span id="cb5-1"><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">MF_DETECTED_OS</span> <span class="ch" style="color: #20794D;
background-color: null;
font-style: inherit;">:=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;"> </span><span class="ch" style="color: #20794D;
background-color: null;
font-style: inherit;">$(</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">shell</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;"> \</span></span>
<span id="cb5-2"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">    _uname="</span><span class="ch" style="color: #20794D;
background-color: null;
font-style: inherit;">$$</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">(uname -a)"; \</span></span>
<span id="cb5-3"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">    if echo "</span><span class="ch" style="color: #20794D;
background-color: null;
font-style: inherit;">$$</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">{_uname}" | grep -q Darwin; then \</span></span>
<span id="cb5-4"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">        echo "macOS"; \</span></span>
<span id="cb5-5"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">    elif echo "</span><span class="ch" style="color: #20794D;
background-color: null;
font-style: inherit;">$$</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">{_uname}" | grep -q WSL2; then \</span></span>
<span id="cb5-6"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">        echo "WSL2"; \</span></span>
<span id="cb5-7"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">    elif echo "</span><span class="ch" style="color: #20794D;
background-color: null;
font-style: inherit;">$$</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">{_uname}" | grep -q Ubuntu; then \</span></span>
<span id="cb5-8"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">        echo "Ubuntu"; \</span></span>
<span id="cb5-9"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">    else \</span></span>
<span id="cb5-10"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">        echo "Unknown"; \</span></span>
<span id="cb5-11"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">    fi</span><span class="ch" style="color: #20794D;
background-color: null;
font-style: inherit;">)</span></span></code></pre></div></div>
<p><code>uname -a</code> の出力から OS を判定しています。<code>ifeq</code> と組み合わせることでターゲット内の処理を OS ごとに分岐できます。Vim のビルドオプション (<code>--enable-darwin</code> vs <code>--without-x</code>) の切り替えに使用していました。</p>
</section>
<section id="defineendef-による設定ファイル管理" class="level3">
<h3 class="anchored" data-anchor-id="defineendef-による設定ファイル管理">3.5. define/endef による設定ファイル管理</h3>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb6" style="background: #f1f3f5;"><pre class="sourceCode makefile code-with-copy"><code class="sourceCode makefile"><span id="cb6-1"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">define</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">MF_WSLCONF_IN_WSL</span></span>
<span id="cb6-2"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">[boot]</span></span>
<span id="cb6-3"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">systemd=true</span></span>
<span id="cb6-4"></span>
<span id="cb6-5"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">[interop]</span></span>
<span id="cb6-6"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">appendWindowsPath=true</span></span>
<span id="cb6-7"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">endef</span></span>
<span id="cb6-8"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">export</span><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;"> MF_WSLCONF_IN_WSL</span></span></code></pre></div></div>
<p><code>define</code>/<code>endef</code> で複数行テキストを変数に格納し、<code>tee</code> で設定ファイルに書き出しています。WSL の設定ファイル (<code>/etc/wsl.conf</code>, <code>.wslconfig</code>) を Makefile 内で一元管理できるのが利点です。</p>
</section>
<section id="vimneovim-ソースビルド" class="level3">
<h3 class="anchored" data-anchor-id="vimneovim-ソースビルド">3.6. Vim/Neovim ソースビルド</h3>
<p>コメントアウトされていますが、<code>ghq get -p</code> でリポジトリを取得してからソースビルドするレシピが残っています。macOS では <code>--enable-darwin</code> と <code>--enable-clipboard</code>、Linux では <code>--without-x</code> を指定する点が OS ごとの差異です。Nix に移行後は <code>programs.vim</code> で宣言的に管理しています。</p>
</section>
</section>
<section id="まとめ" class="level2">
<h2 class="anchored" data-anchor-id="まとめ">4. まとめ</h2>
<p>タスク・ランナーとしての Makefile は <code>.ONESHELL:</code> や <code>define</code>/<code>endef</code> を活用すればシェルスクリプトの管理ツールとして十分機能します。特に自己文書化 help ターゲットは他のプロジェクトでも使える汎用的なパターンです。Nix に移行した今は不要になりましたが、Nix を使わない環境では今でも有用な選択肢だと思います。</p>


<div class="social-share"><a href="https://twitter.com/share?url=https%3A%2F%2Fi9wa4.github.io%2Fblog%2F2026-03-17-makefile-task-runner.html&amp;text=Makefile%20%E3%82%BF%E3%82%B9%E3%82%AF%E3%83%BB%E3%83%A9%E3%83%B3%E3%83%8A%E3%83%BC%E3%81%AE%E4%BE%9B%E9%A4%8A%20%E2%80%93%20uma-chan%E2%80%99s%20page" target="_blank" class="twitter"><i class="bi bi-twitter-x"></i></a><a href="https://bsky.app/intent/compose?text=Makefile%20%E3%82%BF%E3%82%B9%E3%82%AF%E3%83%BB%E3%83%A9%E3%83%B3%E3%83%8A%E3%83%BC%E3%81%AE%E4%BE%9B%E9%A4%8A%20%E2%80%93%20uma-chan%E2%80%99s%20page%20https%3A%2F%2Fi9wa4.github.io%2Fblog%2F2026-03-17-makefile-task-runner.html" target="_blank" class="bsky"><i class="bi bi-bluesky"></i></a><a href="https://www.linkedin.com/shareArticle?url=https%3A%2F%2Fi9wa4.github.io%2Fblog%2F2026-03-17-makefile-task-runner.html&amp;title=Makefile%20%E3%82%BF%E3%82%B9%E3%82%AF%E3%83%BB%E3%83%A9%E3%83%B3%E3%83%8A%E3%83%BC%E3%81%AE%E4%BE%9B%E9%A4%8A%20%E2%80%93%20uma-chan%E2%80%99s%20page" target="_blank" class="linkedin"><i class="bi bi-linkedin"></i></a></div>
</section>

 ]]></description>
  <category>blog</category>
  <category>tech-others</category>
  <guid>https://i9wa4.github.io/blog/2026-03-17-makefile-task-runner.html</guid>
  <pubDate>Tue, 17 Mar 2026 03:00:00 GMT</pubDate>
  <media:content url="https://i9wa4.github.io/assets/common/icon_hhkb3_large.jpg" medium="image" type="image/jpeg"/>
</item>
<item>
  <title>Claude Code と Codex CLI の設定を Nix で SSOT 化する</title>
  <dc:creator>uma-chan </dc:creator>
  <link>https://i9wa4.github.io/blog/2026-03-15-agent-config-ssot-nix.html</link>
  <description><![CDATA[ 





<section id="背景" class="level2">
<h2 class="anchored" data-anchor-id="背景">1. 背景</h2>
<p>最近、私の開発環境には Claude Code と Codex CLI が同居しています。</p>
<p>2つのエージェントが動くようになってから困ったのが設定の二重管理です。 「git push を禁止する」「context7 MCP サーバーを使う」といったルールを、両方のツール用に別々のファイルへ書いていると、片方を更新したときにもう片方へのバックポートを忘れます。 実際に忘れました。</p>
<p>そこで Nix home-manager を使って設定要素を SSOT (Single Source of Truth) 化しました。 設定は <code>nix/home-manager/agents/</code> ディレクトリ以下にまとめています。</p>
<table class="caption-top table">
<colgroup>
<col style="width: 34%">
<col style="width: 65%">
</colgroup>
<thead>
<tr class="header">
<th>ファイル</th>
<th>役割</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td>denied-bash-commands.nix</td>
<td>拒否コマンドリスト (Claude Code + Codex CLI)</td>
</tr>
<tr class="even">
<td>mcp-servers.nix</td>
<td>共有 MCP サーバー定義</td>
</tr>
<tr class="odd">
<td>agent-skills.nix</td>
<td>Agent Skills の宣言的管理</td>
</tr>
<tr class="even">
<td>subagents/</td>
<td>専門調査エージェントの役割定義 (7種)</td>
</tr>
<tr class="odd">
<td>claude-code.nix</td>
<td>Claude Code の home-manager モジュール</td>
</tr>
<tr class="even">
<td>codex-cli.nix</td>
<td>Codex CLI の home-manager モジュール</td>
</tr>
</tbody>
</table>
</section>
<section id="ssot-化した要素" class="level2">
<h2 class="anchored" data-anchor-id="ssot-化した要素">2. SSOT 化した要素</h2>
<section id="拒否コマンドリスト" class="level3">
<h3 class="anchored" data-anchor-id="拒否コマンドリスト">2.1. 拒否コマンドリスト</h3>
<p>Nix のリストとして拒否コマンドを定義し、2つの異なるツール向けの設定を自動生成します。</p>
<div class="code-with-filename">
<div class="code-with-filename-file">
<pre><strong>denied-bash-commands.nix</strong></pre>
</div>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb1" data-filename="denied-bash-commands.nix" style="background: #f1f3f5;"><pre class="sourceCode nix code-with-copy"><code class="sourceCode nix"><span id="cb1-1"><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span></span>
<span id="cb1-2">  <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span></span>
<span id="cb1-3">    <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">argv</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"git"</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"-C"</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">];</span></span>
<span id="cb1-4">    <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">justification</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"cross-directory git operations are denied"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-5">  <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span></span>
<span id="cb1-6">  <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span></span>
<span id="cb1-7">    <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">argv</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"git"</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"push"</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">];</span></span>
<span id="cb1-8">    <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">justification</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"pushing is denied"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-9">  <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span></span>
<span id="cb1-10">  <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span></span>
<span id="cb1-11">    <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">argv</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"git"</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"rebase"</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">];</span></span>
<span id="cb1-12">    <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">justification</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"rebase is denied"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-13">  <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span></span>
<span id="cb1-14">  <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span></span>
<span id="cb1-15">    <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">argv</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"git"</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"reset"</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">];</span></span>
<span id="cb1-16">    <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">justification</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"reset is denied"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-17">  <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span></span>
<span id="cb1-18">  <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span></span>
<span id="cb1-19">    <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">argv</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"git"</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"commit"</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--amend"</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">];</span></span>
<span id="cb1-20">    <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">justification</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"amend is denied (causes force push requirement)"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-21">  <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span></span>
<span id="cb1-22">  <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span></span>
<span id="cb1-23">    <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">argv</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"git"</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"merge"</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">];</span></span>
<span id="cb1-24">    <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">justification</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"merge is denied"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-25">  <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span></span>
<span id="cb1-26">  <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span></span>
<span id="cb1-27">    <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">argv</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"git"</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"branch"</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"-d"</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">];</span></span>
<span id="cb1-28">    <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">justification</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"branch deletion is denied"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-29">  <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span></span>
<span id="cb1-30">  <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span></span>
<span id="cb1-31">    <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">argv</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"git"</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"branch"</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"-D"</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">];</span></span>
<span id="cb1-32">    <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">justification</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"branch force-deletion is denied"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-33">  <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span></span>
<span id="cb1-34">  <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span></span>
<span id="cb1-35">    <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">argv</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"rm"</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">];</span></span>
<span id="cb1-36">    <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">justification</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"rm is denied; use mv /tmp/ instead"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-37">    <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">claudeSettingsJson</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">true</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-38">  <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span></span>
<span id="cb1-39">  <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span></span>
<span id="cb1-40">    <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">argv</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sudo"</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">];</span></span>
<span id="cb1-41">    <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">justification</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sudo is denied"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-42">    <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">claudeSettingsJson</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">true</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-43">  <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span></span>
<span id="cb1-44"><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">]</span></span></code></pre></div></div>
</div>
<p>各エントリの必須フィールドは <code>argv</code> と <code>justification</code> の2つだけです。</p>
<table class="caption-top table">
<colgroup>
<col style="width: 18%">
<col style="width: 4%">
<col style="width: 77%">
</colgroup>
<thead>
<tr class="header">
<th>フィールド</th>
<th>必須</th>
<th>用途</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td>argv</td>
<td>Yes</td>
<td>トークン配列 (Codex CLI + Claude Code hook の両方で使用)</td>
</tr>
<tr class="even">
<td>justification</td>
<td>Yes</td>
<td>拒否時に表示するメッセージ (Claude Code hook + Codex CLI 共通)</td>
</tr>
<tr class="odd">
<td>claudeSettingsJson</td>
<td>No</td>
<td>true → <code>~/.claude/settings.json</code> の permissions.deny にも追加</td>
</tr>
<tr class="even">
<td>anchored</td>
<td>No</td>
<td>false → hookRegex に <code>^</code> を付けない (wrapper prefix bypass 対策)</td>
</tr>
<tr class="odd">
<td>hookRegex</td>
<td>No</td>
<td>指定すると argv からの自動導出を上書きし、そのまま使用する</td>
</tr>
</tbody>
</table>
<p><code>claudeSettingsJson</code> を省略すると hook のみで拒否します。拒否時に <code>justification</code> のメッセージが表示されるため、Claude は代替手段を理解できます。 <code>rm</code> や <code>sudo</code> のように絶対に実行させたくないコマンドには <code>claudeSettingsJson = true</code> を設定し、Claude が計画段階で試行しないようにします。</p>
<p><code>denied-bash-commands.nix</code> はデータだけでなく変換ロジックも内包するモジュールです。 <code>{ pkgs }</code> を受け取り、各ツール向けの出力を事前に計算して返します。</p>
<div class="code-with-filename">
<div class="code-with-filename-file">
<pre><strong>denied-bash-commands.nix (モジュール部分)</strong></pre>
</div>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb2" data-filename="denied-bash-commands.nix (モジュール部分)" style="background: #f1f3f5;"><pre class="sourceCode nix code-with-copy"><code class="sourceCode nix"><span id="cb2-1"><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">pkgs</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span>:</span>
<span id="cb2-2"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">let</span></span>
<span id="cb2-3">  <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">entries</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span>.. ]; # 上記のエントリリスト</span>
<span id="cb2-4"></span>
<span id="cb2-5">  # hookRegex を argv から自動導出</span>
<span id="cb2-6">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># 1 token → ^token\b, 2+ tokens → ^token1.*token2 (末尾 \b なし)</span></span>
<span id="cb2-7">  mkHookRegex = cmd:</span>
<span id="cb2-8">    cmd<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span>hookRegex or <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span></span>
<span id="cb2-9">      <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">let</span></span>
<span id="cb2-10">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">anchored</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> cmd<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span>anchored <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">or</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">true</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb2-11">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">prefix</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> anchored <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">then</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^"</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb2-12">      <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span></span>
<span id="cb2-13">      <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">builtins</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span>length cmd<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span>argv == <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span></span>
<span id="cb2-14">      <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">then</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">${</span>prefix<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}${</span><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">builtins</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span>head cmd<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span>argv<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}\\</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">b"</span></span>
<span id="cb2-15">      <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> prefix <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">builtins</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span>concatStringsSep <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">".*"</span> cmd<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span>argv</span>
<span id="cb2-16">    <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span>;</span>
<span id="cb2-17"></span>
<span id="cb2-18">  mkPrefixRule = cmd:</span>
<span id="cb2-19">    let</span>
<span id="cb2-20">      escapedJustification = <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">builtins</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span>replaceStrings <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\\</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\"</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">]</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\\\\</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\\\"</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">]</span> cmd<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span>justification;</span>
<span id="cb2-21">    in</span>
<span id="cb2-22">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">''</span></span>
<span id="cb2-23"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">      prefix_rule(</span></span>
<span id="cb2-24"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">          pattern = [</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">${</span>patternItems<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">],</span></span>
<span id="cb2-25"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">          decision = "forbidden",</span></span>
<span id="cb2-26"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">          justification = "</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">${</span>escapedJustification<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">",</span></span>
<span id="cb2-27"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">      )</span></span>
<span id="cb2-28"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">    ''</span>;</span>
<span id="cb2-29">in</span>
<span id="cb2-30"><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span></span>
<span id="cb2-31">  <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">inherit</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">entries</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb2-32">  <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">claudeCode</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span></span>
<span id="cb2-33">    <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">denyPermissions</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span>..; # claudeSettingsJson = <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">true</span> のエントリのみ</span>
<span id="cb2-34">    patternsFile = <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span>..;    # 全エントリの hookRegex <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> justification</span>
<span id="cb2-35">  <span class="er" style="color: #AD0000;
background-color: null;
font-style: inherit;">}</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb2-36">  <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">codexCli</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span></span>
<span id="cb2-37">    <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">rulesContent</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span>..;    # 全エントリの prefix_rule</span>
<span id="cb2-38">  <span class="er" style="color: #AD0000;
background-color: null;
font-style: inherit;">}</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb2-39"><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span></span></code></pre></div></div>
</div>
<p>これにより、<code>claude-code.nix</code> と <code>codex-cli.nix</code> のコードは出力を使うだけになります。</p>
<div class="code-with-filename">
<div class="code-with-filename-file">
<pre><strong>claude-code.nix</strong></pre>
</div>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb3" data-filename="claude-code.nix" style="background: #f1f3f5;"><pre class="sourceCode nix code-with-copy"><code class="sourceCode nix"><span id="cb3-1">deniedBash = <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">import</span> <span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">./denied-bash-commands.nix</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">inherit</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">pkgs</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span>;</span>
<span id="cb3-2"></span>
<span id="cb3-3"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># permissions.deny (claudeSettingsJson = true のエントリのみ)</span></span>
<span id="cb3-4">permissions<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span>deny = deniedBash<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span>claudeCode<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span>denyPermissions <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">++</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span>.. ];</span>
<span id="cb3-5"></span>
<span id="cb3-6"># PreToolUse hook 用パターンファイルを含む scripts ディレクトリ <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>全エントリ<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span></span>
<span id="cb3-7">home<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span>file<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">".claude/scripts"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span>source = scriptsDir;</span></code></pre></div></div>
</div>
<div class="code-with-filename">
<div class="code-with-filename-file">
<pre><strong>codex-cli.nix</strong></pre>
</div>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb4" data-filename="codex-cli.nix" style="background: #f1f3f5;"><pre class="sourceCode nix code-with-copy"><code class="sourceCode nix"><span id="cb4-1">deniedBash = <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">import</span> <span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">./denied-bash-commands.nix</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">inherit</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">pkgs</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span>;</span>
<span id="cb4-2"></span>
<span id="cb4-3"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># default.rules (全エントリ)</span></span>
<span id="cb4-4">rulesContent = deniedBash<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span>codexCli<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span>rulesContent;</span></code></pre></div></div>
</div>
<p>変換ロジックが <code>denied-bash-commands.nix</code> に集約されているため、新しいエントリの追加はデータを追加するだけです。 <code>home-manager switch</code> を1回実行すれば、Claude Code の <code>deny-bash-patterns.sh</code> (+ <code>claudeSettingsJson = true</code> があれば <code>settings.json</code>) と Codex CLI の <code>~/.codex/rules/default.rules</code> に反映されます。</p>
<section id="生成結果の具体例" class="level4">
<h4 class="anchored" data-anchor-id="生成結果の具体例">2.1.1. 生成結果の具体例</h4>
<p>エントリを1つ追加したとき、各ファイルに何が生成されるかを示します。</p>
<p>hook のみのエントリの場合:</p>
<div class="code-with-filename">
<div class="code-with-filename-file">
<pre><strong>denied-bash-commands.nix (追加するエントリ)</strong></pre>
</div>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb5" data-filename="denied-bash-commands.nix (追加するエントリ)" style="background: #f1f3f5;"><pre class="sourceCode nix code-with-copy"><code class="sourceCode nix"><span id="cb5-1"><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">argv</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"git"</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"merge"</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">];</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">anchored</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">false</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">justification</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"merge is denied"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span></span></code></pre></div></div>
</div>
<table class="caption-top table">
<colgroup>
<col style="width: 27%">
<col style="width: 72%">
</colgroup>
<thead>
<tr class="header">
<th>生成先</th>
<th>生成内容</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td><code>~/.claude/scripts/deny-bash-patterns.sh</code></td>
<td>DENY_PATTERNS に <code>'git.*merge'</code>、DENY_JUSTIFICATIONS に <code>'merge is denied'</code> を追加</td>
</tr>
<tr class="even">
<td><code>~/.codex/rules/default.rules</code></td>
<td><code>prefix_rule(pattern = ["git", "merge"], decision = "forbidden", justification = "merge is denied")</code> を追加</td>
</tr>
<tr class="odd">
<td><code>~/.claude/settings.json</code></td>
<td>変更なし</td>
</tr>
</tbody>
</table>
<p><code>claudeSettingsJson = true</code> を付けた場合:</p>
<div class="code-with-filename">
<div class="code-with-filename-file">
<pre><strong>denied-bash-commands.nix (追加するエントリ)</strong></pre>
</div>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb6" data-filename="denied-bash-commands.nix (追加するエントリ)" style="background: #f1f3f5;"><pre class="sourceCode nix code-with-copy"><code class="sourceCode nix"><span id="cb6-1"><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">argv</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"rm"</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">];</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">justification</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"rm is denied; use mv /tmp/ instead"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">claudeSettingsJson</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">true</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span></span></code></pre></div></div>
</div>
<table class="caption-top table">
<colgroup>
<col style="width: 26%">
<col style="width: 73%">
</colgroup>
<thead>
<tr class="header">
<th>生成先</th>
<th>生成内容</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td><code>~/.claude/scripts/deny-bash-patterns.sh</code></td>
<td>DENY_PATTERNS に <code>'^rm\b'</code>、DENY_JUSTIFICATIONS に <code>'rm is denied; use mv /tmp/ instead'</code> を追加</td>
</tr>
<tr class="even">
<td><code>~/.codex/rules/default.rules</code></td>
<td><code>prefix_rule(pattern = ["rm"], decision = "forbidden", justification = "rm is denied; use mv /tmp/ instead")</code> を追加</td>
</tr>
<tr class="odd">
<td><code>~/.claude/settings.json</code></td>
<td>permissions.deny に <code>Bash(rm *)</code> を追加</td>
</tr>
</tbody>
</table>
<p><code>argv</code> の長さによって hookRegex と claudeGlob の導出ルールが変わります。</p>
<table class="caption-top table">
<colgroup>
<col style="width: 15%">
<col style="width: 28%">
<col style="width: 56%">
</colgroup>
<thead>
<tr class="header">
<th>argv の長さ</th>
<th>hookRegex の導出</th>
<th>claudeGlob の導出 (claudeSettingsJson 時)</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td>1 token</td>
<td><code>^token\b</code></td>
<td><code>token *</code></td>
</tr>
<tr class="even">
<td>2+ tokens</td>
<td><code>^token1.*token2</code></td>
<td>tokens をスペースで結合 + <code>*</code></td>
</tr>
</tbody>
</table>
</section>
<section id="pretooluse-hook-スクリプト" class="level4">
<h4 class="anchored" data-anchor-id="pretooluse-hook-スクリプト">2.1.2. PreToolUse hook スクリプト</h4>
<p>Claude Code は <code>settings.json</code> の <code>hooks.PreToolUse</code> で Bash コマンド実行前にスクリプトを呼び出します。 このスクリプトが <code>deny-bash-patterns.sh</code> を source し、コマンドをパターンマッチで検査します。</p>
<div class="code-with-filename">
<div class="code-with-filename-file">
<pre><strong>claude-pretooluse-deny-bash.sh</strong></pre>
</div>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb7" data-filename="claude-pretooluse-deny-bash.sh" style="background: #f1f3f5;"><pre class="sourceCode bash code-with-copy"><code class="sourceCode bash"><span id="cb7-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#!/usr/bin/env bash</span></span>
<span id="cb7-2"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">set</span> <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">-o</span> errexit</span>
<span id="cb7-3"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">set</span> <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">-o</span> nounset</span>
<span id="cb7-4"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">set</span> <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">-o</span> pipefail</span>
<span id="cb7-5"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">set</span> <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">-o</span> posix</span>
<span id="cb7-6"></span>
<span id="cb7-7"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># claude-pretooluse-deny-bash.sh - Bash command deny hook</span></span>
<span id="cb7-8"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Hook: PreToolUse | Matcher: Bash</span></span>
<span id="cb7-9"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Patterns: deny-bash-patterns.sh (generated from denied-bash-commands.nix)</span></span>
<span id="cb7-10"></span>
<span id="cb7-11"><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">SCRIPT_DIR</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$(</span><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">cd</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$(</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">dirname</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$0</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">)</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">&amp;&amp;</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">pwd</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">)</span></span>
<span id="cb7-12"><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">PATTERNS_FILE</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$SCRIPT_DIR</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">/deny-bash-patterns.sh"</span></span>
<span id="cb7-13"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">[[</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">!</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">-f</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$PATTERNS_FILE</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">]]</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">&amp;&amp;</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">exit</span> 0</span>
<span id="cb7-14"></span>
<span id="cb7-15"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># shellcheck source=/dev/null</span></span>
<span id="cb7-16"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">source</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$PATTERNS_FILE</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span></span>
<span id="cb7-17"></span>
<span id="cb7-18"><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">COMMAND</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$(</span><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">jq</span> <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">-r</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'.tool_input.command // empty'</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span>/dev/null<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">)</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">||</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">true</span></span>
<span id="cb7-19"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">[[</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">-z</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$COMMAND</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">]]</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">&amp;&amp;</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">exit</span> 0</span>
<span id="cb7-20"></span>
<span id="cb7-21"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">while</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">IFS</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">$';&amp;|'</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">read</span> <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">-ra</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">line_fragments</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">;</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">do</span></span>
<span id="cb7-22">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> fragment <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">${line_fragments</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[@]</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">}</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">;</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">do</span></span>
<span id="cb7-23">    <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">fragment</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">${fragment</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">${fragment</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%%</span>[![:space:]]<span class="pp" style="color: #AD0000;
background-color: null;
font-style: inherit;">*</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">}</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">}</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span></span>
<span id="cb7-24">    <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">fragment</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">${fragment</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">${fragment</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">##</span><span class="pp" style="color: #AD0000;
background-color: null;
font-style: inherit;">*</span>[![:space:]]<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">}</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">}</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span></span>
<span id="cb7-25">    <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">[[</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">-z</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$fragment</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">]]</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">&amp;&amp;</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">continue</span></span>
<span id="cb7-26">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> i <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">${</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">DENY_PATTERNS</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[@]</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">}</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">;</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">do</span></span>
<span id="cb7-27">      <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">[[</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$fragment</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=~</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">${DENY_PATTERNS</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$i</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">]</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">}</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">]];</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">then</span></span>
<span id="cb7-28">        <span class="ex" style="color: null;
background-color: null;
font-style: inherit;">jq</span> <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">-n</span> <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">--arg</span> reason <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Command denied: </span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">${DENY_JUSTIFICATIONS</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$i</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">]</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">}</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"$'</span><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'"Fragment: </span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$fragment</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">\</span></span>
<span id="cb7-29">          <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'{ hookSpecificOutput: { hookEventName: "PreToolUse", permissionDecision: "deny", permissionDecisionReason: $reason } }'</span></span>
<span id="cb7-30">        <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">exit</span> 0</span>
<span id="cb7-31">      <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">fi</span></span>
<span id="cb7-32">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">done</span></span>
<span id="cb7-33">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">done</span></span>
<span id="cb7-34"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">done</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;&lt;&lt;</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$COMMAND</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span></span>
<span id="cb7-35"></span>
<span id="cb7-36"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">exit</span> 0</span></code></pre></div></div>
</div>
<p>スクリプトは <code>dirname $0</code> で自身のディレクトリを解決し、同じディレクトリにある <code>deny-bash-patterns.sh</code> を source します。 引数でパスを渡す必要はありません。</p>
<p><code>claude-code.nix</code> では、リポジトリのスクリプトと生成ファイルを1つの Nix store ディレクトリに合成しています。</p>
<div class="code-with-filename">
<div class="code-with-filename-file">
<pre><strong>claude-code.nix</strong></pre>
</div>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb8" data-filename="claude-code.nix" style="background: #f1f3f5;"><pre class="sourceCode nix code-with-copy"><code class="sourceCode nix"><span id="cb8-1">bashDenyPatternsName = <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"deny-bash-patterns.sh"</span>;</span>
<span id="cb8-2"></span>
<span id="cb8-3">scriptsDir = pkgs<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span>runCommand <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"claude-scripts"</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">''</span></span>
<span id="cb8-4"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">  mkdir -p $out</span></span>
<span id="cb8-5"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">  for f in </span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">${</span><span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">./scripts</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">/*; do</span></span>
<span id="cb8-6"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">    ln -s "$f" "$out/$(basename "$f")"</span></span>
<span id="cb8-7"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">  done</span></span>
<span id="cb8-8"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">  ln -s </span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">${</span>deniedBash<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span>claudeCode<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span>patternsFile<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;"> $out/</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">${</span>bashDenyPatternsName<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span></span>
<span id="cb8-9"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">''</span>;</span>
<span id="cb8-10"></span>
<span id="cb8-11"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># hooks.PreToolUse</span></span>
<span id="cb8-12">command = <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"$CLAUDE_CONFIG_DIR/scripts/claude-pretooluse-deny-bash.sh"</span>;</span>
<span id="cb8-13"></span>
<span id="cb8-14"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># home.file</span></span>
<span id="cb8-15"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">".claude/scripts"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span>source = scriptsDir;</span></code></pre></div></div>
</div>
<p><code>$CLAUDE_CONFIG_DIR</code> は Claude Code が設定する環境変数で、通常は <code>~/.claude</code> を指します。 <code>bashDenyPatternsName</code> を変更すれば生成ファイル名を変えられますが、スクリプト側の修正は不要です。</p>
</section>
</section>
<section id="mcp-サーバー設定" class="level3">
<h3 class="anchored" data-anchor-id="mcp-サーバー設定">2.2. MCP サーバー設定</h3>
<p><code>mcp-servers.nix</code> は Claude Code と Codex CLI が共有する MCP サーバー定義を返す関数です。</p>
<div class="code-with-filename">
<div class="code-with-filename-file">
<pre><strong>mcp-servers.nix</strong></pre>
</div>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb9" data-filename="mcp-servers.nix" style="background: #f1f3f5;"><pre class="sourceCode nix code-with-copy"><code class="sourceCode nix"><span id="cb9-1"><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span></span>
<span id="cb9-2">  <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">pkgs</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span></span>
<span id="cb9-3">  <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">inputs</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span></span>
<span id="cb9-4"><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span>:</span>
<span id="cb9-5"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">let</span></span>
<span id="cb9-6">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># mcp-servers-nix で管理されているサーバー (Nix でバージョン固定)</span></span>
<span id="cb9-7">  <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">nixServers</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span></span>
<span id="cb9-8">    <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>inputs<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span>mcp<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span>servers<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span>nix<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span>lib<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span>evalModule pkgs <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span></span>
<span id="cb9-9">      <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">programs</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span></span>
<span id="cb9-10">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">context7</span>.<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">enable</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">true</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb9-11">      <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">};</span></span>
<span id="cb9-12">    <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}).</span>config<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span>settings<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span>servers<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb9-13"></span>
<span id="cb9-14">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># mcp-servers-nix 未収録のサーバー (uvx またはインストール済みバイナリで実行)</span></span>
<span id="cb9-15">  <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">manualServers</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span></span>
<span id="cb9-16">    <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">awslabs-aws-documentation-mcp-server</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span></span>
<span id="cb9-17">      <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">command</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"uvx"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb9-18">      <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">args</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"awslabs.aws-documentation-mcp-server@latest"</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">];</span></span>
<span id="cb9-19">    <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">};</span></span>
<span id="cb9-20">    <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">drawio</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span></span>
<span id="cb9-21">      <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">command</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"drawio-mcp"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb9-22">    <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">};</span></span>
<span id="cb9-23">  <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">};</span></span>
<span id="cb9-24"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span></span>
<span id="cb9-25">nixServers <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">//</span> manualServers</span></code></pre></div></div>
</div>
<p>2層構造になっています。</p>
<ul>
<li><code>nixServers</code> は <code>mcp-servers-nix</code> flake input を使って Nix 管理下に置いたサーバー群</li>
<li><code>manualServers</code> はまだ <code>mcp-servers-nix</code> に収録されていないサーバー群 (呼び出し方はサーバーごとに異なる)</li>
</ul>
<p><code>nixServers // manualServers</code> で合成した attrset を <code>claude-code.nix</code> と <code>codex-cli.nix</code> の両方が <code>import ./mcp-servers.nix</code> で読み込みます。 1箇所に追加するだけで両エージェントに配布されます。</p>
</section>
<section id="agent-skills" class="level3">
<h3 class="anchored" data-anchor-id="agent-skills">2.3. Agent Skills</h3>
<p><code>agent-skills.nix</code> は <code>agent-skills-nix</code> home-manager モジュールを使った宣言的なスキル管理です。</p>
<div class="code-with-filename">
<div class="code-with-filename-file">
<pre><strong>agent-skills.nix</strong></pre>
</div>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb10" data-filename="agent-skills.nix" style="background: #f1f3f5;"><pre class="sourceCode nix code-with-copy"><code class="sourceCode nix"><span id="cb10-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Agent skills declarative management via agent-skills-nix</span></span>
<span id="cb10-2"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># cf. https://github.com/Kyure-A/agent-skills-nix</span></span>
<span id="cb10-3"><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span></span>
<span id="cb10-4">  <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">inputs</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span></span>
<span id="cb10-5">  <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">config</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span></span>
<span id="cb10-6">  <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">...</span></span>
<span id="cb10-7"><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span>:</span>
<span id="cb10-8"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">let</span></span>
<span id="cb10-9">  <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">homeDir</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> config<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span>home<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span>homeDirectory<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb10-10"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span></span>
<span id="cb10-11"><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span></span>
<span id="cb10-12">  <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">imports</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span></span>
<span id="cb10-13">    inputs<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span>agent-skills<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span>homeManagerModules<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span>default</span>
<span id="cb10-14">  <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">];</span></span>
<span id="cb10-15"></span>
<span id="cb10-16">  <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">programs</span>.<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">agent-skills</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span></span>
<span id="cb10-17">    <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">enable</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">true</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb10-18"></span>
<span id="cb10-19">    <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Skill sources</span></span>
<span id="cb10-20">    <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">sources</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span></span>
<span id="cb10-21">      <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Local skills from this dotfiles repository</span></span>
<span id="cb10-22">      <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">local</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span></span>
<span id="cb10-23">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">path</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> inputs<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span>self<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb10-24">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">subdir</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"agents/skills"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb10-25">      <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">};</span></span>
<span id="cb10-26">      <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># tmux-a2a-postman skills</span></span>
<span id="cb10-27">      <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">tmux-a2a-postman</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span></span>
<span id="cb10-28">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">path</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> inputs<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span>tmux<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span>a2a<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span>postman<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb10-29">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">subdir</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"skills"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb10-30">      <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">};</span></span>
<span id="cb10-31">      <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># dbt-labs official agent skills (split by skill group)</span></span>
<span id="cb10-32">      <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">dbt</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span></span>
<span id="cb10-33">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">path</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> inputs<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span>dbt<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span>agent<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span>skills<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb10-34">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">subdir</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"skills/dbt/skills"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb10-35">      <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">};</span></span>
<span id="cb10-36">      <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">dbt-migration</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span></span>
<span id="cb10-37">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">path</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> inputs<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span>dbt<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span>agent<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span>skills<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb10-38">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">subdir</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"skills/dbt-migration/skills"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb10-39">      <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">};</span></span>
<span id="cb10-40">      <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Anthropic official agent skills</span></span>
<span id="cb10-41">      <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">anthropic</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span></span>
<span id="cb10-42">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">path</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> inputs<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span>anthropic<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span>skills<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb10-43">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">subdir</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"skills"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb10-44">      <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">};</span></span>
<span id="cb10-45">      <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Streamlit official agent skills</span></span>
<span id="cb10-46">      <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">streamlit</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span></span>
<span id="cb10-47">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">path</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> inputs<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span>streamlit<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span>skills<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb10-48">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">subdir</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"developing-with-streamlit/skills"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb10-49">      <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">};</span></span>
<span id="cb10-50">      <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Databricks official agent skills (ai-dev-kit)</span></span>
<span id="cb10-51">      <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># cf. https://github.com/databricks-solutions/ai-dev-kit/tree/main/databricks-skills</span></span>
<span id="cb10-52">      <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">databricks</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span></span>
<span id="cb10-53">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">path</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> inputs<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span>databricks<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span>agent<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span>skills<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb10-54">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">subdir</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"databricks-skills"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb10-55">      <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">};</span></span>
<span id="cb10-56">      <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># cf. https://github.com/databricks-solutions/ai-dev-kit/tree/main/.claude/skills</span></span>
<span id="cb10-57">      <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">databricks-claude</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span></span>
<span id="cb10-58">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">path</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> inputs<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span>databricks<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span>agent<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span>skills<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb10-59">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">subdir</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">".claude/skills"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb10-60">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">filter</span>.<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">nameRegex</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"python-dev"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span> <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># exclude databricks-python-sdk (duplicate)</span></span>
<span id="cb10-61">      <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">};</span></span>
<span id="cb10-62">      <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Databricks official agent skills (databricks org)</span></span>
<span id="cb10-63">      <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># cf. https://github.com/databricks/databricks-agent-skills</span></span>
<span id="cb10-64">      <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">databricks-official</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span></span>
<span id="cb10-65">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">path</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> inputs<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span>databricks<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span>official<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span>skills<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb10-66">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">subdir</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"skills"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb10-67">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">filter</span>.<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">nameRegex</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"databricks(-apps|-pipelines)?"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span> <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># exclude databricks-jobs (duplicate)</span></span>
<span id="cb10-68">      <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">};</span></span>
<span id="cb10-69">      <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># draw.io skill (jgraph/drawio-mcp)</span></span>
<span id="cb10-70">      <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># cf. https://github.com/jgraph/drawio-mcp</span></span>
<span id="cb10-71">      <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">drawio-mcp</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span></span>
<span id="cb10-72">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">path</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> inputs<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span>drawio<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span>mcp<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb10-73">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">subdir</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"skill-cli"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb10-74">      <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">};</span></span>
<span id="cb10-75">      <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># freee MCP skills</span></span>
<span id="cb10-76">      <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># cf. https://github.com/freee/freee-mcp</span></span>
<span id="cb10-77">      <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">freee</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span></span>
<span id="cb10-78">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">path</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> inputs<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span>freee<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span>mcp<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb10-79">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">subdir</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"skills"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb10-80">      <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">};</span></span>
<span id="cb10-81">      <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># HashiCorp agent skills (split by plugin)</span></span>
<span id="cb10-82">      <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># cf. https://github.com/hashicorp/agent-skills</span></span>
<span id="cb10-83">      <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">hashicorp-terraform-codegen</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span></span>
<span id="cb10-84">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">path</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> inputs<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span>hashicorp<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span>agent<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span>skills<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb10-85">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">subdir</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"terraform/code-generation/skills"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb10-86">      <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">};</span></span>
<span id="cb10-87">      <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">hashicorp-terraform-module</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span></span>
<span id="cb10-88">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">path</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> inputs<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span>hashicorp<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span>agent<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span>skills<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb10-89">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">subdir</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"terraform/module-generation/skills"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb10-90">      <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">};</span></span>
<span id="cb10-91">      <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">hashicorp-terraform-provider</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span></span>
<span id="cb10-92">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">path</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> inputs<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span>hashicorp<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span>agent<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span>skills<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb10-93">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">subdir</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"terraform/provider-development/skills"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb10-94">      <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">};</span></span>
<span id="cb10-95">    <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">};</span></span>
<span id="cb10-96"></span>
<span id="cb10-97">    <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Enable all skills from all sources</span></span>
<span id="cb10-98">    <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">skills</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span></span>
<span id="cb10-99">      <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">enableAll</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">true</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb10-100">      <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Explicit skill definitions (for rename or custom config)</span></span>
<span id="cb10-101">      <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">explicit</span>.<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">databricks-jobs-bundles</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span></span>
<span id="cb10-102">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">from</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"databricks-official"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb10-103">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">path</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"databricks-jobs"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb10-104">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">rename</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"databricks-jobs-bundles"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span> <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># avoid duplicate with ai-dev-kit</span></span>
<span id="cb10-105">      <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">};</span></span>
<span id="cb10-106">    <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">};</span></span>
<span id="cb10-107"></span>
<span id="cb10-108">    <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Target destinations (symlink-tree uses activation rsync)</span></span>
<span id="cb10-109">    <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">targets</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span></span>
<span id="cb10-110">      <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Claude Code: ~/.claude/skills</span></span>
<span id="cb10-111">      <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">claude-home</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span></span>
<span id="cb10-112">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">dest</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">${</span>homeDir<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">/.claude/skills"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb10-113">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">structure</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"symlink-tree"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb10-114">      <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">};</span></span>
<span id="cb10-115">      <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Codex CLI: ~/.codex/skills</span></span>
<span id="cb10-116">      <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">codex</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span></span>
<span id="cb10-117">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">dest</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">${</span>homeDir<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">/.codex/skills"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb10-118">        <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">structure</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"symlink-tree"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb10-119">      <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">};</span></span>
<span id="cb10-120">    <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">};</span></span>
<span id="cb10-121"></span>
<span id="cb10-122">    <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Preserve .system directory (created by agents at runtime)</span></span>
<span id="cb10-123">    <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">excludePatterns</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"/.system"</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">];</span></span>
<span id="cb10-124">  <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">};</span></span>
<span id="cb10-125"><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span></span></code></pre></div></div>
</div>
<p>ポイントは <code>targets</code> に複数の宛先を書けることです。 <code>~/.claude/skills</code> と <code>~/.codex/skills</code> の両方が同一ソースからシンボリックツリーとして展開されます。</p>
<p><code>enableAll = true</code> で全スキルを有効にしつつ、重複する名前のスキルは <code>filter.nameRegex</code> や <code>rename</code> で解決しています。</p>
<p><code>excludePatterns = [ "/.system" ]</code> は、エージェントが実行時に <code>skills/</code> 配下に書き込む <code>.system/</code> ディレクトリを rsync 対象から除外するための設定です。 これがないと <code>home-manager switch</code> のたびに実行時状態が消えます。</p>
</section>
<section id="サブエージェント" class="level3">
<h3 class="anchored" data-anchor-id="サブエージェント">2.4. サブエージェント</h3>
<p><code>subagents/</code> には Claude Code の Agent ツールで呼び出せる専門調査エージェントの役割定義が入っています。</p>
<p>各ファイルは YAML フロントマター (<code>name</code>, <code>description</code>, <code>model</code>) と Markdown 本文で構成されています。 <code>subagents/*.md</code> が単一のソースで、ツールごとに異なる形式に変換されます。</p>
<ul>
<li><code>claude-code.nix</code> は <code>subagents/</code> を <code>~/.claude/agents/</code> にシンボリックリンクし、生の <code>.md</code> ファイルを Claude Code に渡します。</li>
<li><code>codex-cli.nix</code> は Nix ビルド時に各 <code>.md</code> を <code>.toml</code> に変換し、<code>~/.codex/agents/</code> に配置します。<code>model</code> フィールドは削除されるため、エージェントは親セッションのモデルを継承します。</li>
</ul>
<div class="code-with-filename">
<div class="code-with-filename-file">
<pre><strong>codex-cli.nix</strong></pre>
</div>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb11" data-filename="codex-cli.nix" style="background: #f1f3f5;"><pre class="sourceCode nix code-with-copy"><code class="sourceCode nix"><span id="cb11-1">codexAgentsDir = pkgs<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span>runCommand <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"codex-agents"</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">''</span></span>
<span id="cb11-2"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">  mkdir -p $out</span></span>
<span id="cb11-3"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">  for md in </span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">${</span><span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">./subagents</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">/*.md; do</span></span>
<span id="cb11-4"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">    basename="$(basename "$md" .md)"</span></span>
<span id="cb11-5"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">    agent_name="$(</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">${</span>pkgs<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span>gnused<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">/bin/sed -n 's/^name: //p' "$md")"</span></span>
<span id="cb11-6"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">    description="$(</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">${</span>pkgs<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span>gnused<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">/bin/sed -n 's/^description: //p' "$md")"</span></span>
<span id="cb11-7"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">    body="$(</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">${</span>pkgs<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span>gawk<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">/bin/awk 'BEGIN{n=0} /^---$/{n++; next} n&gt;=2{print}' "$md")"</span></span>
<span id="cb11-8"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">    printf 'name = "%s"\ndescription = "%s"\ndeveloper_instructions = """\n%s\n"""\n' \</span></span>
<span id="cb11-9"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">      "$agent_name" "$description" "$body" &gt; "$out/$basename.toml"</span></span>
<span id="cb11-10"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">  done</span></span>
<span id="cb11-11"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">''</span>;</span></code></pre></div></div>
</div>
<table class="caption-top table">
<thead>
<tr class="header">
<th>エージェント</th>
<th>用途</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td>researcher-tech</td>
<td>技術調査・リサーチ</td>
</tr>
<tr class="even">
<td>reviewer-architecture</td>
<td>設計パターン・構造レビュー</td>
</tr>
<tr class="odd">
<td>reviewer-code</td>
<td>コード品質・可読性レビュー</td>
</tr>
<tr class="even">
<td>reviewer-data</td>
<td>データ品質・スキーマ設計レビュー</td>
</tr>
<tr class="odd">
<td>reviewer-historian</td>
<td>コンテキスト・変更経緯の把握</td>
</tr>
<tr class="even">
<td>reviewer-qa</td>
<td>テストカバレッジ・エッジケースレビュー</td>
</tr>
<tr class="odd">
<td>reviewer-security</td>
<td>セキュリティ・脆弱性レビュー</td>
</tr>
</tbody>
</table>
<p><code>subagents/</code> は denied-bash-commands・mcp-servers・agent-skills と同様に Nix が管理する要素です。 <code>subagents/*.md</code> を1箇所更新して <code>home-manager switch</code> を実行するだけで、Claude Code と Codex CLI の両方に反映されます。</p>
</section>
</section>
<section id="実装のはまりポイント" class="level2">
<h2 class="anchored" data-anchor-id="実装のはまりポイント">3. 実装のはまりポイント</h2>
<section id="settings.json-はシンボリックリンクにできない" class="level3">
<h3 class="anchored" data-anchor-id="settings.json-はシンボリックリンクにできない">3.1. settings.json はシンボリックリンクにできない</h3>
<p><code>claude-code.nix</code> の実装で一点注意が必要な箇所があります。</p>
<p><code>settings.json</code> の配置です。</p>
<p>他の設定ファイル (<code>CLAUDE.md</code>, <code>rules/</code>, <code>agents/</code>) は Nix ストアへのシンボリックリンクとして配置できます。 読み取り専用で構いません。</p>
<p>しかし <code>settings.json</code> だけは違います。</p>
<p>Claude Code のインタラクティブな <code>/config</code> エディタがユーザーの設定変更を <code>settings.json</code> に書き戻します。 Nix ストアのシンボリックリンクは読み取り専用なので、書き込みに失敗してしまいます。</p>
<p>なお、MCP サーバーの接続状態などのランタイム状態が実際に書き込まれるのは <code>~/.claude/.claude.json</code> の方です。</p>
<p>そのため <code>home-manager</code> の activation スクリプトで <code>install -Dm644</code> を使い、書き込み可能なファイルとしてコピーしています。</p>
<div class="code-with-filename">
<div class="code-with-filename-file">
<pre><strong>claude-code.nix</strong></pre>
</div>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb12" data-filename="claude-code.nix" style="background: #f1f3f5;"><pre class="sourceCode nix code-with-copy"><code class="sourceCode nix"><span id="cb12-1">claudeSettings = lib<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span>hm<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span>dag<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span>entryAfter <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"writeBoundary"</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">]</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">''</span></span>
<span id="cb12-2"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">  install -Dm644 </span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">${</span>settingsFile<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;"> "$HOME/.claude/settings.json"</span></span>
<span id="cb12-3"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">''</span>;</span></code></pre></div></div>
</div>
<p><code>home-manager switch</code> を実行するたびに最新の設定で上書きコピーされます。 <code>/config</code> エディタで加えた変更はこのコピー先に書き込まれ、次の <code>switch</code> で上書きされます。</p>
<p>MCP サーバーの登録は別の activation スクリプト (<code>claudeMcpServers</code>) で <code>~/.claude/.claude.json</code> を <code>jq</code> で直接書き換えており、こちらも同様の理由でシンボリックリンクではなく実ファイルを対象にしています。</p>
</section>
<section id="codex-cli-の-trusted-projects-は動的生成" class="level3">
<h3 class="anchored" data-anchor-id="codex-cli-の-trusted-projects-は動的生成">3.2. Codex CLI の trusted projects は動的生成</h3>
<p><code>codex-cli.nix</code> の activation スクリプトは <code>fd</code> で <code>~/ghq</code> 以下の全 git リポジトリを検索し、<code>config.toml</code> に <code>trust_level = "trusted"</code> エントリを追記します。</p>
<div class="code-with-filename">
<div class="code-with-filename-file">
<pre><strong>codex-cli.nix</strong></pre>
</div>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb13" data-filename="codex-cli.nix" style="background: #f1f3f5;"><pre class="sourceCode nix code-with-copy"><code class="sourceCode nix"><span id="cb13-1">$<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">pkgs</span>.<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">fd</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span><span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">/bin/fd</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">--</span>type d <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">--</span>hidden <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">--</span>no<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span>ignore <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\.</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">git$"</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">${</span>ghqRoot<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">--</span>max<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span>depth <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>&gt;<span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">/dev/null</span> |</span>
<span id="cb13-2">  sort |</span>
<span id="cb13-3">  while read <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span>r gitdir; do</span>
<span id="cb13-4">    repo=$<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>dirname <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"$gitdir"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span></span>
<span id="cb13-5">    echo <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span></span>
<span id="cb13-6">    echo <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"[projects.</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\"</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">$repo/</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\"</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">]"</span></span>
<span id="cb13-7">    echo <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"trust_level = </span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\"</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">trusted</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\"</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span></span>
<span id="cb13-8">  done &gt;&gt; <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"$_output"</span></span></code></pre></div></div>
</div>
<p>新しいリポジトリを <code>ghq get</code> で取得したあと <code>home-manager switch</code> を1回実行するだけで、そのリポジトリも自動的に trusted になります。 手動で <code>config.toml</code> を編集する必要はありません。</p>
</section>
<section id="agent-skills.nix-の込み入った設定" class="level3">
<h3 class="anchored" data-anchor-id="agent-skills.nix-の込み入った設定">3.3. agent-skills.nix の込み入った設定</h3>
<p><code>agent-skills.nix</code> には、ドキュメントを読んだだけでは意図が分かりにくい部分がいくつかあります。</p>
<section id="subdir-で-auto-discovery-の対象を絞る" class="level4">
<h4 class="anchored" data-anchor-id="subdir-で-auto-discovery-の対象を絞る">3.3.1. subdir で auto-discovery の対象を絞る</h4>
<p>スキルリポジトリのルート直下に <code>SKILL.md</code> がない場合、<code>subdir</code> で discovery の起点を指定します。</p>
<p><code>drawio-mcp</code> リポジトリの例では、<code>SKILL.md</code> は <code>skill-cli/drawio/SKILL.md</code> にあります。 <code>subdir = "skill-cli"</code> を指定すると、auto-discovery が <code>skill-cli/</code> 以下を探索して <code>drawio</code> スキルを発見します。</p>
<div class="code-with-filename">
<div class="code-with-filename-file">
<pre><strong>agent-skills.nix</strong></pre>
</div>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb14" data-filename="agent-skills.nix" style="background: #f1f3f5;"><pre class="sourceCode nix code-with-copy"><code class="sourceCode nix"><span id="cb14-1">drawio<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span>mcp = <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span></span>
<span id="cb14-2">  <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">path</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> inputs<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span>drawio<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span>mcp<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb14-3">  <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">subdir</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"skill-cli"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb14-4"><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span>;</span></code></pre></div></div>
</div>
</section>
<section id="重複するスキル名への対処" class="level4">
<h4 class="anchored" data-anchor-id="重複するスキル名への対処">3.3.2. 重複するスキル名への対処</h4>
<p>複数のソースに同名のスキルが存在する場合、2つの方法で対処できます。</p>
<p>1つ目は <code>filter.nameRegex</code> による allowlist フィルタです。 指定した正規表現に一致するスキルだけが auto-discovery の対象になります。</p>
<div class="code-with-filename">
<div class="code-with-filename-file">
<pre><strong>agent-skills.nix</strong></pre>
</div>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb15" data-filename="agent-skills.nix" style="background: #f1f3f5;"><pre class="sourceCode nix code-with-copy"><code class="sourceCode nix"><span id="cb15-1">databricks<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span>official = <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span></span>
<span id="cb15-2">  <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">path</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> inputs<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span>databricks<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span>official<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span>skills<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb15-3">  <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">subdir</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"skills"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb15-4">  <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">filter</span>.<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">nameRegex</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"databricks(-apps|-pipelines)?"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span> <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># exclude databricks-jobs (duplicate)</span></span>
<span id="cb15-5"><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span>;</span></code></pre></div></div>
</div>
<p><code>databricks</code>、<code>databricks-apps</code>、<code>databricks-pipelines</code> だけを含め、<code>databricks-jobs</code> は除外しています。 ai-dev-kit 側に同名のスキルが存在するための回避策です。</p>
<p>2つ目は <code>skills.explicit</code> と <code>rename</code> の組み合わせです。 除外した側のスキルを別名でロードすることで、両方を共存させられます。</p>
<div class="code-with-filename">
<div class="code-with-filename-file">
<pre><strong>agent-skills.nix</strong></pre>
</div>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb16" data-filename="agent-skills.nix" style="background: #f1f3f5;"><pre class="sourceCode nix code-with-copy"><code class="sourceCode nix"><span id="cb16-1">skills = <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span></span>
<span id="cb16-2">  <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">enableAll</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">true</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb16-3">  <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">explicit</span>.<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">databricks-jobs-bundles</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span></span>
<span id="cb16-4">    <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">from</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"databricks-official"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb16-5">    <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">path</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"databricks-jobs"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb16-6">    <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">rename</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"databricks-jobs-bundles"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span> <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># avoid duplicate with ai-dev-kit</span></span>
<span id="cb16-7">  <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">};</span></span>
<span id="cb16-8"><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span>;</span></code></pre></div></div>
</div>
<p><code>databricks-official</code> ソースの <code>databricks-jobs</code> を <code>databricks-jobs-bundles</code> という別名でロードしています。</p>
</section>
<section id="excludepatterns-で-codex-cli-のシステムスキルを守る" class="level4">
<h4 class="anchored" data-anchor-id="excludepatterns-で-codex-cli-のシステムスキルを守る">3.3.3. excludePatterns で Codex CLI のシステムスキルを守る</h4>
<p><code>agent-skills-nix</code> の activation スクリプトは <code>rsync --delete</code> で各ターゲットディレクトリを同期します。 <code>--delete</code> はソース側に存在しないファイルをターゲットから削除するオプションです。</p>
<p>Codex CLI はバイナリにシステムスキル (<code>skill-creator</code>, <code>skill-installer</code> 等) を埋め込んでいます (<a href="https://github.com/openai/codex/blob/main/codex-rs/skills/src/lib.rs">ソースコード</a>)。 起動時に <code>~/.codex/skills/.system/</code> へ展開し、<code>.codex-system-skills.marker</code> にフィンガープリントを書き込みます。 次回以降はフィンガープリントが一致すれば展開をスキップし、Codex のバージョンが変わると再展開します。</p>
<div class="code-with-filename">
<div class="code-with-filename-file">
<pre><strong>~/.codex/skills/.system/</strong></pre>
</div>
<pre class="text" data-filename="~/.codex/skills/.system/"><code>.codex-system-skills.marker
skill-creator/
skill-installer/</code></pre>
</div>
<p>この <code>.system/</code> は Nix の管理するスキルバンドルには存在しません。 <code>home-manager switch</code> で <code>rsync --delete</code> が走ると <code>.system/</code> ごと削除されてしまいます。 削除されても次回の Codex 起動時に再展開されますが、毎回フルコピーが走るのは無駄です。</p>
<div class="code-with-filename">
<div class="code-with-filename-file">
<pre><strong>agent-skills.nix</strong></pre>
</div>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb18" data-filename="agent-skills.nix" style="background: #f1f3f5;"><pre class="sourceCode nix code-with-copy"><code class="sourceCode nix"><span id="cb18-1">excludePatterns = <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"/.system"</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">]</span>;</span></code></pre></div></div>
</div>
<p>先頭の <code>/</code> は rsync の exclude パターン構文で「ターゲットディレクトリ直下のみ」を意味します。 <code>/.system</code> はルート直下の <code>.system/</code> だけを除外し、個別スキル内部の <code>.system/</code> には影響しません。</p>
<p>なお <code>agent-skills-nix</code> のデフォルト値も <code>[ "/.system" ]</code> です。 明示的に書いているのは、この除外が Codex CLI の動作に必要であることを設定ファイル上で明確にするためです。</p>
</section>
</section>
</section>
<section id="まとめ" class="level2">
<h2 class="anchored" data-anchor-id="まとめ">4. まとめ</h2>
<section id="ssot-化した4要素" class="level3">
<h3 class="anchored" data-anchor-id="ssot-化した4要素">4.1. SSOT 化した4要素</h3>
<table class="caption-top table">
<colgroup>
<col style="width: 22%">
<col style="width: 32%">
<col style="width: 44%">
</colgroup>
<thead>
<tr class="header">
<th>要素</th>
<th>ファイル / ディレクトリ</th>
<th>読み込み先</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td>拒否コマンド</td>
<td>denied-bash-commands.nix</td>
<td>claude-code.nix, codex-cli.nix</td>
</tr>
<tr class="even">
<td>MCP サーバー</td>
<td>mcp-servers.nix</td>
<td>claude-code.nix, codex-cli.nix</td>
</tr>
<tr class="odd">
<td>Agent Skills</td>
<td>agent-skills.nix</td>
<td>~/.claude/skills, ~/.codex/skills</td>
</tr>
<tr class="even">
<td>サブエージェント</td>
<td>subagents/</td>
<td>AGENTS.md (section 9.3)</td>
</tr>
</tbody>
</table>
</section>
<section id="やってみて" class="level3">
<h3 class="anchored" data-anchor-id="やってみて">4.2. やってみて</h3>
<p>設定の二重管理から解放されたのが一番大きいです。</p>
<p>「Claude Code に追加したけど Codex CLI に忘れた」が構造的に起きなくなりました。</p>
<p>Nix で管理するとビルドエラーで設定ミスが事前に検出できるのも地味に助かっています。 JSON や TOML を手書きしていたときは起動してみて初めてエラーに気づいていたので。</p>
<p><code>agent-skills-nix</code> を使ったマルチソースのスキル管理はまだ日本語の情報が少ないので、参考になれば幸いです。</p>


<div class="social-share"><a href="https://twitter.com/share?url=https%3A%2F%2Fi9wa4.github.io%2Fblog%2F2026-03-15-agent-config-ssot-nix.html&amp;text=Claude%20Code%20%E3%81%A8%20Codex%20CLI%20%E3%81%AE%E8%A8%AD%E5%AE%9A%E3%82%92%20Nix%20%E3%81%A7%20SSOT%20%E5%8C%96%E3%81%99%E3%82%8B%20%E2%80%93%20uma-chan%E2%80%99s%20page" target="_blank" class="twitter"><i class="bi bi-twitter-x"></i></a><a href="https://bsky.app/intent/compose?text=Claude%20Code%20%E3%81%A8%20Codex%20CLI%20%E3%81%AE%E8%A8%AD%E5%AE%9A%E3%82%92%20Nix%20%E3%81%A7%20SSOT%20%E5%8C%96%E3%81%99%E3%82%8B%20%E2%80%93%20uma-chan%E2%80%99s%20page%20https%3A%2F%2Fi9wa4.github.io%2Fblog%2F2026-03-15-agent-config-ssot-nix.html" target="_blank" class="bsky"><i class="bi bi-bluesky"></i></a><a href="https://www.linkedin.com/shareArticle?url=https%3A%2F%2Fi9wa4.github.io%2Fblog%2F2026-03-15-agent-config-ssot-nix.html&amp;title=Claude%20Code%20%E3%81%A8%20Codex%20CLI%20%E3%81%AE%E8%A8%AD%E5%AE%9A%E3%82%92%20Nix%20%E3%81%A7%20SSOT%20%E5%8C%96%E3%81%99%E3%82%8B%20%E2%80%93%20uma-chan%E2%80%99s%20page" target="_blank" class="linkedin"><i class="bi bi-linkedin"></i></a></div>
</section>
</section>

 ]]></description>
  <category>blog</category>
  <category>tech-ai</category>
  <guid>https://i9wa4.github.io/blog/2026-03-15-agent-config-ssot-nix.html</guid>
  <pubDate>Sun, 15 Mar 2026 07:21:50 GMT</pubDate>
  <media:content url="https://i9wa4.github.io/assets/common/icon_hhkb3_large.jpg" medium="image" type="image/jpeg"/>
</item>
<item>
  <title>ターミナル上でのファイルビューアーとしてサクっと Neovim を使ってみる</title>
  <dc:creator>uma-chan </dc:creator>
  <link>https://i9wa4.github.io/zenn/2026-03-15-neovim-as-file-viewer.html</link>
  <description><![CDATA[ 





<section id="zenn-リンク先" class="level2">
<h2 class="anchored" data-anchor-id="zenn-リンク先">Zenn リンク先</h2>
<p>この記事は Zenn で公開されています。</p>
<p><a href="https://zenn.dev/i9wa4/articles/2026-03-15-neovim-as-file-viewer">ターミナル上でのファイルビューアーとしてサクっと Neovim を使ってみる</a></p>


</section>

 ]]></description>
  <category>zenn</category>
  <category>neovim</category>
  <category>cli</category>
  <category>terminal</category>
  <guid>https://i9wa4.github.io/zenn/2026-03-15-neovim-as-file-viewer.html</guid>
  <pubDate>Sun, 15 Mar 2026 06:30:00 GMT</pubDate>
  <media:content url="https://i9wa4.github.io/assets/common/zenn-ogp.png" medium="image" type="image/png" height="76" width="144"/>
</item>
<item>
  <title>lazygit で AI コミットメッセージ生成</title>
  <dc:creator>uma-chan </dc:creator>
  <link>https://i9wa4.github.io/blog/2026-03-14-lazygit-commit-message.html</link>
  <description><![CDATA[ 





<section id="はじめに" class="level2">
<h2 class="anchored" data-anchor-id="はじめに">1. はじめに</h2>
<p>lazygit のカスタムコマンド機能を使い、ステージ済みの diff を Claude (Haiku) に渡してコミットメッセージを自動生成する設定を作りました。小ネタです。</p>
</section>
<section id="設定" class="level2">
<h2 class="anchored" data-anchor-id="設定">2. 設定</h2>
<div class="code-with-filename">
<div class="code-with-filename-file">
<pre><strong>lazygit.nix</strong></pre>
</div>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb1" data-filename="lazygit.nix" style="background: #f1f3f5;"><pre class="sourceCode nix code-with-copy"><code class="sourceCode nix"><span id="cb1-1">programs<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span>lazygit<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span>settings<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">.</span>customCommands = <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span></span>
<span id="cb1-2">  <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span></span>
<span id="cb1-3">    <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">key</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"&lt;c-g&gt;"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-4">    <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">context</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"files"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-5">    <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">output</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"terminal"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-6">    <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">command</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">''</span></span>
<span id="cb1-7"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">      MSG=$(git diff --cached | claude --no-session-persistence --print --model haiku \</span></span>
<span id="cb1-8"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">        'Generate ONLY a one-line Git commit message following Conventional Commits format \</span></span>
<span id="cb1-9"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">        (type(scope): description). Types: feat, fix, docs, style, refactor, test, chore. \</span></span>
<span id="cb1-10"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">        Based strictly on the diff from stdin. Output ONLY the message, nothing else.') \</span></span>
<span id="cb1-11"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">        &amp;&amp; git commit -e -m "$MSG"</span></span>
<span id="cb1-12"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">    ''</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-13">  <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span></span>
<span id="cb1-14"><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">]</span>;</span></code></pre></div></div>
</div>
<p><code>output = "terminal"</code> にすることで <code>git commit -e</code> がターミナル上で動き、エディタが開きます。</p>
</section>
<section id="使い方" class="level2">
<h2 class="anchored" data-anchor-id="使い方">3. 使い方</h2>
<ol type="1">
<li>lazygit でファイルをステージする</li>
<li>files パネルで <code>Ctrl+G</code> を押す</li>
<li>Claude Haiku が diff を読んでコミットメッセージを生成する</li>
<li>エディタが生成されたメッセージを pre-fill した状態で開く</li>
<li>内容を確認・修正してコミット</li>
</ol>
<p>モデルは Haiku を指定しているので速くて安上がりです。</p>
</section>
<section id="まとめ" class="level2">
<h2 class="anchored" data-anchor-id="まとめ">4. まとめ</h2>
<p><code>git diff --cached</code> をそのまま LLM に渡すシンプルな構成で、実用的な下書きが得られます。 最終確認はエディタで自分の目を通すので、完全に任せきりにならないのがちょうどいいバランスです。</p>


<div class="social-share"><a href="https://twitter.com/share?url=https%3A%2F%2Fi9wa4.github.io%2Fblog%2F2026-03-14-lazygit-commit-message.html&amp;text=lazygit%20%E3%81%A7%20AI%20%E3%82%B3%E3%83%9F%E3%83%83%E3%83%88%E3%83%A1%E3%83%83%E3%82%BB%E3%83%BC%E3%82%B8%E7%94%9F%E6%88%90%20%E2%80%93%20uma-chan%E2%80%99s%20page" target="_blank" class="twitter"><i class="bi bi-twitter-x"></i></a><a href="https://bsky.app/intent/compose?text=lazygit%20%E3%81%A7%20AI%20%E3%82%B3%E3%83%9F%E3%83%83%E3%83%88%E3%83%A1%E3%83%83%E3%82%BB%E3%83%BC%E3%82%B8%E7%94%9F%E6%88%90%20%E2%80%93%20uma-chan%E2%80%99s%20page%20https%3A%2F%2Fi9wa4.github.io%2Fblog%2F2026-03-14-lazygit-commit-message.html" target="_blank" class="bsky"><i class="bi bi-bluesky"></i></a><a href="https://www.linkedin.com/shareArticle?url=https%3A%2F%2Fi9wa4.github.io%2Fblog%2F2026-03-14-lazygit-commit-message.html&amp;title=lazygit%20%E3%81%A7%20AI%20%E3%82%B3%E3%83%9F%E3%83%83%E3%83%88%E3%83%A1%E3%83%83%E3%82%BB%E3%83%BC%E3%82%B8%E7%94%9F%E6%88%90%20%E2%80%93%20uma-chan%E2%80%99s%20page" target="_blank" class="linkedin"><i class="bi bi-linkedin"></i></a></div>
</section>

 ]]></description>
  <category>blog</category>
  <category>tech-ai</category>
  <guid>https://i9wa4.github.io/blog/2026-03-14-lazygit-commit-message.html</guid>
  <pubDate>Fri, 13 Mar 2026 15:00:00 GMT</pubDate>
  <media:content url="https://i9wa4.github.io/assets/common/icon_hhkb3_large.jpg" medium="image" type="image/jpeg"/>
</item>
<item>
  <title></title>
  <dc:creator>uma-chan </dc:creator>
  <link>https://i9wa4.github.io/slides/2026-03-06-kenro-py.html</link>
  <description><![CDATA[ undefined ]]></description>
  <category>slides</category>
  <category>kenro-py</category>
  <guid>https://i9wa4.github.io/slides/2026-03-06-kenro-py.html</guid>
  <pubDate>Thu, 05 Mar 2026 15:00:00 GMT</pubDate>
  <media:content url="https://i9wa4.github.io/assets/common/icon_hhkb3_large.jpg" medium="image" type="image/jpeg"/>
</item>
<item>
  <title></title>
  <dc:creator>uma-chan </dc:creator>
  <link>https://i9wa4.github.io/slides/2026-03-05-multi-agent-orchestration.html</link>
  <description><![CDATA[ undefined ]]></description>
  <category>slides</category>
  <category>genda</category>
  <guid>https://i9wa4.github.io/slides/2026-03-05-multi-agent-orchestration.html</guid>
  <pubDate>Wed, 04 Mar 2026 15:00:00 GMT</pubDate>
  <media:content url="https://i9wa4.github.io/assets/common/icon_hhkb3_large.jpg" medium="image" type="image/jpeg"/>
</item>
<item>
  <title></title>
  <dc:creator>Mawatari Daiki</dc:creator>
  <link>https://i9wa4.github.io/slides/2026-02-13-databricks-cfp-demo.html</link>
  <description><![CDATA[ undefined ]]></description>
  <category>slides</category>
  <category>genda</category>
  <guid>https://i9wa4.github.io/slides/2026-02-13-databricks-cfp-demo.html</guid>
  <pubDate>Thu, 12 Feb 2026 15:00:00 GMT</pubDate>
  <media:content url="https://i9wa4.github.io/assets/common/icon_hhkb3_large.jpg" medium="image" type="image/jpeg"/>
</item>
<item>
  <title>AI エージェント時代の波に乗るための tmux 入門 — マルチエージェントオーケストレーションの相棒</title>
  <dc:creator>uma-chan </dc:creator>
  <link>https://i9wa4.github.io/zenn/2026-02-08-tmux-intro-ai-agent-orchestration.html</link>
  <description><![CDATA[ 





<section id="zenn-リンク先" class="level2">
<h2 class="anchored" data-anchor-id="zenn-リンク先">Zenn リンク先</h2>
<p>この記事は Zenn で公開されています。</p>
<p><a href="https://zenn.dev/i9wa4/articles/2026-02-08-tmux-intro-ai-agent-orchestration">AI エージェント時代の波に乗るための tmux 入門 — マルチエージェントオーケストレーションの相棒</a></p>


</section>

 ]]></description>
  <category>zenn</category>
  <category>tmux</category>
  <category>cli</category>
  <category>terminal</category>
  <category>dotfiles</category>
  <category>aiagent</category>
  <guid>https://i9wa4.github.io/zenn/2026-02-08-tmux-intro-ai-agent-orchestration.html</guid>
  <pubDate>Sun, 08 Feb 2026 09:30:00 GMT</pubDate>
  <media:content url="https://i9wa4.github.io/assets/common/zenn-ogp.png" medium="image" type="image/png" height="76" width="144"/>
</item>
<item>
  <title>全部 Databricks に集約して誰でもローカルから操作できる環境 ― エージェント・SQL・Notebook</title>
  <dc:creator>uma-chan </dc:creator>
  <link>https://i9wa4.github.io/zenn/2026-01-27-databricks-goose-starter.html</link>
  <description><![CDATA[ 





<section id="zenn-リンク先" class="level2">
<h2 class="anchored" data-anchor-id="zenn-リンク先">Zenn リンク先</h2>
<p>この記事は Zenn で公開されています。</p>
<p><a href="https://zenn.dev/genda_jp/articles/2026-01-27-databricks-goose-starter">全部 Databricks に集約して誰でもローカルから操作できる環境 ― エージェント・SQL・Notebook</a></p>


</section>

 ]]></description>
  <category>zenn</category>
  <category>databricks</category>
  <category>devcontainer</category>
  <category>goose</category>
  <category>jupyter</category>
  <category>mcp</category>
  <guid>https://i9wa4.github.io/zenn/2026-01-27-databricks-goose-starter.html</guid>
  <pubDate>Mon, 26 Jan 2026 22:30:00 GMT</pubDate>
  <media:content url="https://i9wa4.github.io/assets/common/zenn-ogp.png" medium="image" type="image/png" height="76" width="144"/>
</item>
<item>
  <title>AIコーディングエージェント時代になぜ私は dotfiles を育てるのか</title>
  <dc:creator>uma-chan </dc:creator>
  <link>https://i9wa4.github.io/blog/2026-01-08-why-dotfiles-still-matters-to-me.html</link>
  <description><![CDATA[ 





<section id="claude-code-の進化が示すもの" class="level2">
<h2 class="anchored" data-anchor-id="claude-code-の進化が示すもの">1. Claude Code の進化が示すもの</h2>
<p>Claude Code 開発者の Boris による最近の変更をまとめたポストが話題になっていました。</p>
<blockquote class="twitter-tweet blockquote">
<p lang="ja" dir="ltr">
Claude Codeの開発者Borisが、冬休み期間中に作成したであろう変更をまとめてみた:<br> <br>【機能拡張】<br>・/teleport コマンド、CLI セッションを web/mobile に引き継ぎ<br>・tmux 風にバックグラウンドでエージェント継続実行<br>・Subagentsの frontmatter で hooksを追加可能… <a href="https://t.co/ivKZvzimb3">pic.twitter.com/ivKZvzimb3</a>
</p>
— Oikon (<span class="citation" data-cites="oikon48">@oikon48</span>) <a href="https://twitter.com/oikon48/status/2008125761128144965?ref_src=twsrc%5Etfw">January 5, 2026</a>
</blockquote>
<script async="" src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>
<p>ポスト全文：</p>
<blockquote class="blockquote">
<p><strong>【機能拡張】</strong></p>
<ul>
<li>/teleport コマンド、CLI セッションを web/mobile に引き継ぎ</li>
<li>tmux 風にバックグラウンドでエージェント継続実行</li>
<li>Subagentsの frontmatter で hooksを追加可能</li>
<li>CLAUDE_CODE_FILE_READ_MAX_OUTPUT_TOKENS 、ファイル読み込みの最大出力トークンをカスタマイズ</li>
<li>長時間 CLI セッション完了時にモバイルへ通知</li>
<li>/skill-name でSkillsをスラッシュコマンドとして呼び出し</li>
<li>Subagents の frontmatter で MCPを指定可能</li>
<li>カスタムコマンドレベルでのHooks定義</li>
<li>現在のセッション名の表示</li>
<li>Escキー操作での割り込みの文字色の変更</li>
<li>Subagentsの並列実行およびバックグラウンド実行の無効化設定</li>
</ul>
<p><strong>【バグ修正】</strong></p>
<ul>
<li>–resume –fork-session でのセッションをフォークし過去メッセージに巻き戻し</li>
<li>General Subagentsが親のモデルを継承するよう修正</li>
<li>ターミナルのちらつきを 85% 低減</li>
<li>Web版でPlanモードから復帰できない問題を修正</li>
<li>LSP (Language Server Protocol) 実装のバグ修正</li>
<li>ウィンドウサイズ変更について描画改善</li>
<li>Thinking時の ctrl+O の内容の改善</li>
<li>パイプを使ってclaudeを起動する際のバグを修正</li>
<li>画像サイズが大きい時の自動圧縮</li>
<li>バックグラウンド Subagentsのコンテキストが親に漏れるバグを修正</li>
</ul>
<p>多すぎる😂 分かる範囲なので抜け漏れもあるかもしれない。上記の多くは次回のリリースに入るとのこと。</p>
<p>I’m worried if you got enough rest during your vacation lol, <span class="citation" data-cites="bcherny">@bcherny</span></p>
</blockquote>
<p>これを見てまず思ったのは、</p>
<p><strong>「ターミナルじゃないとできない」とは、いずれ言えなくなる</strong> ということです。</p>
</section>
<section id="機能比較は意味がなくなる" class="level2">
<h2 class="anchored" data-anchor-id="機能比較は意味がなくなる">2. 機能比較は意味がなくなる</h2>
<section id="現時点での比較" class="level3">
<h3 class="anchored" data-anchor-id="現時点での比較">2.1. 現時点での比較</h3>
<p>今 2026/1/7 時点では、ターミナル + Claude Code は並列実行の面で多少の優位性があります (tmux で無制限かつ同一ディレクトリで異なるタスクを実行可能)。</p>
<p>しかし Boris の開発内容を見るに、この差もなくなっていくことになります。</p>
</section>
<section id="収斂する未来" class="level3">
<h3 class="anchored" data-anchor-id="収斂する未来">2.2. 収斂する未来</h3>
<p>Claude Code の VS Code拡張もターミナル版と同じ設定ファイルを使用します。 最近みなさん熱心に育成中と思しき以下の設定群ですね。</p>
<pre class="text"><code>.claude/
├── CLAUDE.md
├── rules/
├── skills/
├── agents/
└── commands/</code></pre>
<p>つまり、 <strong>Claude Code 固有の機能はインターフェースに依存しない</strong> というわけです。</p>
<p>そんな世界に向かっていく中でターミナルを選ぶ理由とは一体何なのか。</p>
</section>
</section>
<section id="残るもの環境構築力" class="level2">
<h2 class="anchored" data-anchor-id="残るもの環境構築力">3. 残るもの：環境構築力</h2>
<section id="ターミナル環境の価値" class="level3">
<h3 class="anchored" data-anchor-id="ターミナル環境の価値">3.1. ターミナル環境の価値</h3>
<p>ターミナル環境の本当の価値は星取り表で比較できるような機能ではないと思います。</p>
<p><strong>ターミナル環境の本当の価値とは、開発環境すべてをテキストファイルで定義し、Git で管理できること</strong> です。</p>
</section>
<section id="unix-哲学との親和性" class="level3">
<h3 class="anchored">3.2. Unix 哲学との親和性</h3>
<p>Claude Code 公式ドキュメントでも謳われています。</p>
<blockquote class="blockquote">
<h2 id="why-developers-love-claude-code" class="anchored" data-anchor-id="unix-哲学との親和性">Why developers love Claude Code</h2>
<ul>
<li><p><strong>Works in your terminal:</strong> Not another chat window. Not another IDE. Claude Code meets you where you already work, with the tools you already love.</p></li>
<li><p><strong>Unix philosophy:</strong> Claude Code is composable and scriptable.</p></li>
</ul>
<p>— <a href="https://code.claude.com/docs/en/overview">Claude Code Overview</a></p>
</blockquote>
<p>ターミナル環境では、AIエージェントをシェルスクリプトや他の CLI ツールと組み合わせて、自分だけの開発環境を構築できます。</p>
</section>
<section id="周辺ツールを自由に付け替えられる" class="level3">
<h3 class="anchored" data-anchor-id="周辺ツールを自由に付け替えられる">3.3. 周辺ツールを自由に付け替えられる</h3>
<p>ターミナル環境では、すべてのツールが交換可能です。</p>
<table class="caption-top table">
<colgroup>
<col style="width: 35%">
<col style="width: 45%">
<col style="width: 18%">
</colgroup>
<thead>
<tr class="header">
<th>レイヤー</th>
<th>選択肢</th>
<th>交換可能性</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td>ターミナルエミュレータ</td>
<td>Ghostty, WezTerm, iTerm2, Kitty</td>
<td>自由に変更可能</td>
</tr>
<tr class="even">
<td>ターミナルマルチプレクサ</td>
<td>tmux, zellij, screen</td>
<td>自由に変更可能</td>
</tr>
<tr class="odd">
<td>シェル</td>
<td>zsh, bash, fish</td>
<td>自由に変更可能</td>
</tr>
<tr class="even">
<td>テキストエディタ</td>
<td>Neovim, Vim, Emacs, Helix</td>
<td>自由に変更可能</td>
</tr>
<tr class="odd">
<td>AIコーディングエージェント</td>
<td>Claude Code, Codex CLI, Gemini CLI</td>
<td>自由に変更可能</td>
</tr>
</tbody>
</table>
<p>ターミナル環境では各レイヤーを独立して進化させられます。</p>
<p>実際私は最近ターミナルを Alacritty, Ghostty, WezTerm と頻繁に乗り換えていますが開発体験は全く変わっていません。</p>
<p>また私の環境では tmux, Vim, Zsh の統合利用を加味したキーバインドをそれぞれのツールに設定していて手に実に馴染みます。</p>
</section>
</section>
<section id="dotfiles-のすすめ" class="level2">
<h2 class="anchored" data-anchor-id="dotfiles-のすすめ">4. dotfiles のすすめ</h2>
<section id="dotfiles-とは" class="level3">
<h3 class="anchored" data-anchor-id="dotfiles-とは">4.1. dotfiles とは</h3>
<p>dotfiles とはホームディレクトリにある設定ファイル群を Git で管理する文化です。</p>
<p>たとえば以下のような構成になります。</p>
<pre class="text"><code>dotfiles/
├── .config/
│   ├── claude/      # AIコーディングエージェント設定
│   ├── tmux/        # ターミナルマルチプレクサ設定
│   ├── wezterm/     # ターミナル設定
│   └── nvim/        # テキストエディタ設定
├── .zshrc            # シェル設定
└── bin/              # 自作スクリプト</code></pre>
</section>
<section id="なぜ-dotfiles-を育てるのか" class="level3">
<h3 class="anchored" data-anchor-id="なぜ-dotfiles-を育てるのか">4.2. なぜ dotfiles を育てるのか</h3>
<section id="環境の再現性" class="level4">
<h4 class="anchored" data-anchor-id="環境の再現性">4.2.1. 環境の再現性</h4>
<p>新しいマシンでも <code>git clone</code> と数コマンドで同じ環境が再現できます。</p>
<p>いつでも再現できるという安心感があるので、快適さを追求して自身の資産にしていくモチベーションが湧きます。</p>
</section>
<section id="進化の軌跡" class="level4">
<h4 class="anchored" data-anchor-id="進化の軌跡">4.2.2. 進化の軌跡</h4>
<p>設定の変更がすべて Git に残ります。</p>
<p>なぜその設定にしたか後から追えますし、過去の状態に戻すことも簡単です。</p>
</section>
<section id="知識の蓄積" class="level4">
<h4 class="anchored" data-anchor-id="知識の蓄積">4.2.3. 知識の蓄積</h4>
<p>dotfiles は「自分がどう働きたいか」の具体化です。</p>
<p>年月をかけて育てた設定は、他では得られない資産になります。</p>
</section>
<section id="共有と学習" class="level4">
<h4 class="anchored" data-anchor-id="共有と学習">4.2.4. 共有と学習</h4>
<p>他人の dotfiles を見て学び、自分の dotfiles を公開して切磋琢磨できます。</p>
<p>dotfiles はテキストファイルなので、AIに読み込ませて「この設定は何をしているのか」「自分の環境に取り入れるにはどうすればいいか」を質問できます。他人の複雑な設定を理解するハードルがかなり下がりました。</p>
<p>以下は2025年で象徴的だなと思った投稿です。</p>
<p>dotfiles を愛する者の間では割と常識になっていた設定についての会話です。 設定なんてものは dotfiles を使っている人以外にはなかなか広まらないんです。 情報格差、感じますよね。</p>
<blockquote class="twitter-tweet blockquote">
<p lang="ja" dir="ltr">
ryoppippiからclaude codeの設定を学ぶといいので、みんなryoppippiのdotfilesも見ような<a href="https://t.co/RduDuxgLml">https://t.co/RduDuxgLml</a> <a href="https://t.co/NJMD3hNyFP">https://t.co/NJMD3hNyFP</a>
</p>
— yasunori🫖<span class="citation" data-cites="loglass">@loglass</span>🐳 (<span class="citation" data-cites="YKirin0418">@YKirin0418</span>) <a href="https://twitter.com/YKirin0418/status/1977585870787301738?ref_src=twsrc%5Etfw">October 13, 2025</a>
</blockquote>
<script async="" src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>
</section>
</section>
<section id="claude-code-設定-周辺環境-最強オレオレ開発環境" class="level3">
<h3 class="anchored" data-anchor-id="claude-code-設定-周辺環境-最強オレオレ開発環境">4.3. Claude Code 設定 + 周辺環境 = 最強オレオレ開発環境</h3>
<p>Claude Code 設定だけなら、IDEでも使えます。しかし……</p>
<pre class="text"><code>dotfiles/
├── .config/
│   ├── claude/         # &lt;- IDEでも使える
│   │   ├── CLAUDE.md
│   │   ├── rules/
│   │   ├── agents/
│   │   └── commands/
│   │
│   ├── tmux/           # &lt;- ターミナル固有
│   │   └── tmux.conf
│   │
│   └── wezterm/        # &lt;- ターミナル固有
│       └── wezterm.lua
│
├── .zshrc               # &lt;- ターミナル固有
│
└── bin/                 # &lt;- ターミナル固有</code></pre>
<p>Claude Code 設定は「点」、dotfiles 全体は「面」ですね。</p>
<p>周辺ツールとの連携によってAIは開発フロー全体に溶け込みます。</p>
</section>
</section>
<section id="dotfiles-の始め方" class="level2">
<h2 class="anchored" data-anchor-id="dotfiles-の始め方">5. dotfiles の始め方</h2>
<p>dotfiles の始め方については、以下の記事が親しみがあってわかりやすいと思いました。</p>
<ul>
<li><a href="https://qiita.com/yutkat/items/c6c7584d9795799ee164">ようこそdotfilesの世界へ - Qiita</a></li>
<li><a href="https://zenn.dev/timetree/articles/904126d3570345">ゆるりとはじめる dotfiles 入門 - Zenn</a></li>
</ul>
<p>dotfiles は一日で完成しません。使いながら情報感度を上げつつ徐々に育てていくものです。</p>
<p>まずは Claude Code の設定など小さいところから始めて、徐々に充実させていくのがおすすめです。</p>
</section>
<section id="まとめ" class="level2">
<h2 class="anchored" data-anchor-id="まとめ">6. まとめ</h2>
<section id="機能は収斂する" class="level3">
<h3 class="anchored" data-anchor-id="機能は収斂する">6.1. 機能は収斂する</h3>
<p>Claude Code の <code>/teleport</code> やバックグラウンド実行が示すように、ターミナルと IDE の機能差はなくなっていきます。</p>
</section>
<section id="残るのは環境構築力" class="level3">
<h3 class="anchored" data-anchor-id="残るのは環境構築力">6.2. 残るのは「環境構築力」</h3>
<p>ターミナル環境の価値はプログラマブル、コンポーザブル、交換可能、ポータブルであることです。 すべてをテキストファイルで定義し、Git で管理できているる環境は Claude Code の機能の収斂後も輝きを失いません。</p>
</section>
<section id="dotfiles-を育てよう" class="level3">
<h3 class="anchored" data-anchor-id="dotfiles-を育てよう">6.3. dotfiles を育てよう</h3>
<p>Claude Code 設定は IDE でも使えます。しかし……</p>
<ul>
<li>スクリプトでワークフロー自動化</li>
<li>自作ツールや最新ツールとの連携</li>
<li>複数ツール間で統一した操作感</li>
</ul>
<p>これらは自分で構築した環境でしか実現できません。</p>
</section>
<section id="そして何より" class="level3">
<h3 class="anchored" data-anchor-id="そして何より">6.4. そして何より</h3>
<p><strong>dotfiles は楽しいのでオススメ！ぜひやろう！生き様を反映させていこう！</strong></p>
<p>これが言いたかっただけです。</p>


<div class="social-share"><a href="https://twitter.com/share?url=https%3A%2F%2Fi9wa4.github.io%2Fblog%2F2026-01-08-why-dotfiles-still-matters-to-me.html&amp;text=AI%E3%82%B3%E3%83%BC%E3%83%87%E3%82%A3%E3%83%B3%E3%82%B0%E3%82%A8%E3%83%BC%E3%82%B8%E3%82%A7%E3%83%B3%E3%83%88%E6%99%82%E4%BB%A3%E3%81%AB%E3%81%AA%E3%81%9C%E7%A7%81%E3%81%AF%20dotfiles%20%E3%82%92%E8%82%B2%E3%81%A6%E3%82%8B%E3%81%AE%E3%81%8B%20%E2%80%93%20uma-chan%E2%80%99s%20page" target="_blank" class="twitter"><i class="bi bi-twitter-x"></i></a><a href="https://bsky.app/intent/compose?text=AI%E3%82%B3%E3%83%BC%E3%83%87%E3%82%A3%E3%83%B3%E3%82%B0%E3%82%A8%E3%83%BC%E3%82%B8%E3%82%A7%E3%83%B3%E3%83%88%E6%99%82%E4%BB%A3%E3%81%AB%E3%81%AA%E3%81%9C%E7%A7%81%E3%81%AF%20dotfiles%20%E3%82%92%E8%82%B2%E3%81%A6%E3%82%8B%E3%81%AE%E3%81%8B%20%E2%80%93%20uma-chan%E2%80%99s%20page%20https%3A%2F%2Fi9wa4.github.io%2Fblog%2F2026-01-08-why-dotfiles-still-matters-to-me.html" target="_blank" class="bsky"><i class="bi bi-bluesky"></i></a><a href="https://www.linkedin.com/shareArticle?url=https%3A%2F%2Fi9wa4.github.io%2Fblog%2F2026-01-08-why-dotfiles-still-matters-to-me.html&amp;title=AI%E3%82%B3%E3%83%BC%E3%83%87%E3%82%A3%E3%83%B3%E3%82%B0%E3%82%A8%E3%83%BC%E3%82%B8%E3%82%A7%E3%83%B3%E3%83%88%E6%99%82%E4%BB%A3%E3%81%AB%E3%81%AA%E3%81%9C%E7%A7%81%E3%81%AF%20dotfiles%20%E3%82%92%E8%82%B2%E3%81%A6%E3%82%8B%E3%81%AE%E3%81%8B%20%E2%80%93%20uma-chan%E2%80%99s%20page" target="_blank" class="linkedin"><i class="bi bi-linkedin"></i></a></div>
</section>
</section>

 ]]></description>
  <category>blog</category>
  <category>tech-ai</category>
  <guid>https://i9wa4.github.io/blog/2026-01-08-why-dotfiles-still-matters-to-me.html</guid>
  <pubDate>Wed, 07 Jan 2026 16:24:41 GMT</pubDate>
  <media:content url="https://i9wa4.github.io/assets/common/icon_hhkb3_large.jpg" medium="image" type="image/jpeg"/>
</item>
</channel>
</rss>
