<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="3.10.0">Jekyll</generator><link href="https://jimmyblog.site/feed.xml" rel="self" type="application/atom+xml" /><link href="https://jimmyblog.site/" rel="alternate" type="text/html" /><updated>2026-04-27T01:44:12+00:00</updated><id>https://jimmyblog.site/feed.xml</id><title type="html">Jimmy’s Blog</title><subtitle>This blog focuses on sharing software development experiences and self-learning journeys, documenting what I build, learn, and explore along the way.</subtitle><entry xml:lang="en"><title type="html">What Are AI Agents?</title><link href="https://jimmyblog.site/en/2026/04/25/what-is-ai-agents/" rel="alternate" type="text/html" title="What Are AI Agents?" /><published>2026-04-25T07:00:00+00:00</published><updated>2026-04-25T07:00:00+00:00</updated><id>https://jimmyblog.site/en/2026/04/25/what-is-ai-agents</id><content type="html" xml:base="https://jimmyblog.site/en/2026/04/25/what-is-ai-agents/"><![CDATA[<p>Lately, whenever I talk with companies about AI adoption, the conversation almost always drifts toward designing an Agent Flow or Agent Design Pattern for their use case — ReAct pattern, Parallel pattern, you name it.</p>

<p>But every time we get there, the same question creeps into my head: <strong>does the task actually need a flow this complex?</strong></p>

<p>Back when model capabilities and context windows weren’t nearly as impressive, I used the Parallel pattern a lot — splitting subtasks across purpose-built agents to keep each one focused. It worked well. During one job interview, I was sharing this experience when the interviewer turned it around on me: “So what do <em>you</em> think an AI Agent actually is?”</p>

<p>As a developer, my gut answer was: an Agent is an LLM wired up to various APIs and MCP tools for external access, calling different tools based on the task at hand — plus context management, intent classification, system prompt tuning, and workflow design. But over time I realized that definition was too shallow, and it’s the kind of gap that leads to real misunderstandings.</p>

<h2 id="defining-ai-agents">Defining AI Agents</h2>

<p>I came across a definition in <em>Agentic Design Patterns</em> by Antonio Gulli that I think is the clearest I’ve seen:</p>

<blockquote>
  <p>AI agent is a system designed to perceive its environment and take actions to achieve a specific goal. It’s an evolution from a standard Large Language Model (LLM), enhanced with the abilities to plan, use tools, and interact with its surroundings.</p>
</blockquote>

<p>A complete Agent System runs through five core steps:</p>

<ol>
  <li><strong>Get The Mission</strong> — receive the task</li>
  <li><strong>Scan The Scene</strong> — perceive the environment</li>
  <li><strong>Think it Through</strong> — plan the strategy</li>
  <li><strong>Take Action</strong> — execute</li>
  <li><strong>Learn and Get Better</strong> — improve from outcomes</li>
</ol>

<p>These five steps are the capability framework of a fully realized Agent. It also explains why Agent design patterns — ReAct, Parallel, Route — exist in the first place: they’re all attempts to layer these capabilities on top of an LLM.</p>

<h2 id="does-my-use-case-actually-need-all-of-that">Does My Use Case Actually Need All of That?</h2>

<p>Once you have a clear definition, the next question becomes: <strong>does your scenario actually require the full stack?</strong></p>

<p>When I’m scoping a client project, I usually ask myself:</p>

<ol>
  <li>Does the task need to be user-initiated, or must the Agent sense its environment autonomously?</li>
  <li>Is the context fixed, or does it change dynamically?</li>
  <li>Does it need to learn from mistakes and improve over time?</li>
</ol>

<p>Take the <strong>Parallel pattern</strong> — it shines in fixed-context, complex-task scenarios. The environment doesn’t change, tasks are pre-assigned, and each Agent just needs to execute its piece without worrying about the bigger picture.</p>

<p>Flip to a <strong>dynamic and unpredictable</strong> scenario, and <strong>ReAct pattern</strong> is the better fit. The Agent needs to continuously read the environment and adjust its strategy as new information comes in — much higher demands on perception and iterative refinement.</p>

<p>No pattern is inherently better than another; it’s all about fit. And figuring out fit means getting honest about what you can and can’t tolerate — which brings me to what I think is unavoidable when designing any Agent: <strong>the AI Agent Iron Triangle</strong>.</p>

<h2 id="the-ai-agent-iron-triangle">The AI Agent Iron Triangle</h2>

<p>In Agent design, I think the same Iron Triangle applies, just with three different vertices: <strong>Accuracy, Latency, and Cost</strong>.</p>

<p><img src="https://static.jimmyblog.site/2026-04-26-what-is-ai-agents/AI_AGENT_IRON_TRIANGLE_2.webp" alt="AI_AGENT_IRON_TRIANGLE" /></p>

<p>You can’t have all three. Know which dimension matters most before you start designing.</p>

<p>This is also why I think SLM (Small Language Model) based Agent Flow still has real research value. In an era where we’re spoiled by powerful large models, it’s easy to forget that <strong>in some cases, a simple SLM Agent Flow is more than enough</strong> — no need to throw money at a problem that doesn’t require it.</p>

<h2 id="the-rise-of-openclaw">The Rise of OpenClaw</h2>

<p>When OpenClaw blew up in early 2026, I got the same question over and over in client conversations: what do I make of its design, and what does it mean for Agent development?</p>

<p>OpenClaw’s success comes down to one thing: it gave the Agent the ability to operate the OS directly — not just calling APIs, but actually using the computer to get things done. The model is still the core, but the interface to the world changed fundamentally. How to achieve similar results with an SLM might be the next real frontier in Agent design.</p>

<p>I love Andrej Karpathy’s framing of LLM applications as an operating system.</p>

<p><img src="https://static.jimmyblog.site/2026-04-26-what-is-ai-agents/LLMOS.webp" alt="LLMOS" /></p>

<p>It inspired me to map the relationship between LLMs and AI Agents onto computer hardware:</p>

<p><img src="https://static.jimmyblog.site/2026-04-26-what-is-ai-agents/AI_AGENT_COMPUTER_SYSTEM_3.webp" alt="AI_AGENT_COMPUTER_SYSTEM" /></p>

<table>
  <thead>
    <tr>
      <th>AI Concept</th>
      <th>Hardware</th>
      <th>Why</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>LLM</td>
      <td>CPU</td>
      <td>Core computation — reasoning, language understanding</td>
    </tr>
    <tr>
      <td>HARNESS</td>
      <td>Motherboard</td>
      <td>Ties everything together, coordinates signal flow</td>
    </tr>
    <tr>
      <td>Tools</td>
      <td>PCIe Slots</td>
      <td>External capabilities (search, code execution, etc.)</td>
    </tr>
    <tr>
      <td>Memory</td>
      <td>RAM</td>
      <td>Short-term memory, current task context</td>
    </tr>
    <tr>
      <td>Vector DB / DB</td>
      <td>Hard Drive</td>
      <td>Long-term storage, retrieved when needed</td>
    </tr>
    <tr>
      <td>System Prompt</td>
      <td>BIOS Settings</td>
      <td>Behavior defined before the system boots</td>
    </tr>
  </tbody>
</table>

<h2 id="back-to-that-original-question">Back to That Original Question</h2>

<p>“So what do you think an AI Agent is?”</p>

<p>After all this, my answer is: an AI Agent is a system that can perceive its environment, form a plan, and take action. But more importantly — <strong>it’s not a universal solution</strong>. Before designing one, getting clear on what your scenario actually needs matters far more than picking the right pattern.</p>

<hr />

<h2 id="reference">Reference</h2>

<ul>
  <li><a href="https://irp.cdn-website.com/ca79032a/files/uploaded/Agentic-Design-Patterns.pdf">Agentic Design Patterns — Antonio Gulli</a></li>
  <li><a href="https://rlancemartin.github.io/2026/01/09/agent_design/">Agentic Design Patterns</a></li>
  <li><a href="https://docs.langchain.com/oss/python/langchain/multi-agent">Multi-agent — LangChain</a></li>
  <li><a href="https://docs.cloud.google.com/architecture/choose-design-pattern-agentic-ai-system">Choose a design pattern for your agentic AI system — Google Cloud</a></li>
  <li><a href="https://www.youtube.com/watch?v=LCEmiRjPEtQ&amp;t=620s">Andrej Karpathy: Software Is Changing (Again)</a></li>
</ul>]]></content><author><name></name></author><category term="AI Agents" /><summary type="html"><![CDATA[Lately, whenever I talk with companies about AI adoption, the conversation almost always drifts toward designing an Agent Flow or Agent Design Pattern for their use case — ReAct pattern, Parallel pattern, you name it.]]></summary></entry><entry xml:lang="zh"><title type="html">什麼是 AI Agents？</title><link href="https://jimmyblog.site/zh/2026/04/25/what-is-ai-agents/" rel="alternate" type="text/html" title="什麼是 AI Agents？" /><published>2026-04-25T07:00:00+00:00</published><updated>2026-04-25T07:00:00+00:00</updated><id>https://jimmyblog.site/zh/2026/04/25/what-is-ai-agents</id><content type="html" xml:base="https://jimmyblog.site/zh/2026/04/25/what-is-ai-agents/"><![CDATA[<p>最近在和不同的公司交流，聊到 AI 應用時，話題常常圍繞著如何為公司或客戶設計一套屬於他們的 Agent Flow，或者說 Agent Design Pattern——可能是 ReAct pattern、Parallel pattern……</p>

<p>但每次聊到這裡，我心裡都會浮現一個疑問：<strong>任務的複雜度，真的需要設計出這麼複雜的流程嗎？</strong></p>

<p>在早期，模型能力與 Context Window 還沒那麼強的時候，我常用 Parallel pattern 將不同子任務分配給預先設計好的 Agent，效果相當顯著——讓模型能更專注在特定任務上。記得有一次面試，我和面試官分享這段經驗，他反問我：「你認為什麼是 AI Agent？」</p>

<p>作為開發者，我當時的直覺是：Agent 就是一個 LLM，背後串接各種 API/MCP 工具存取外部資源，讓 LLM 根據任務需求調用不同工具來完成目標，這其中也包含Context的管理，任務的辨別能力等等…但簡化來說，就是呼叫一次 LLM provider 的 API、管理呼叫API時chat_history的刪減，優化System Prompt(意圖判斷的能力)，並且為工作流程進行設計。</p>

<p>但我漸漸發現，這樣的定義過於簡化，也容易產生認知上的落差。</p>

<h2 id="ai-agent-的定義">AI Agent 的定義</h2>

<p>受益於 <em>Agentic Design Patterns</em>（Antonio Gulli 著），我認為這是我看過對 AI Agent 最清晰明瞭的定義，他說：</p>

<blockquote>
  <p>AI agent is a system designed to perceive its environment and take actions to achieve a specific goal. It’s an evolution from a standard Large Language Model (LLM), enhanced with the abilities to plan, use tools, and interact with its surroundings.</p>
</blockquote>

<p>一個完整的 Agent System 包含以下幾個核心步驟：</p>

<ol>
  <li><strong>Get The Mission</strong> — 接收任務</li>
  <li><strong>Scan The Scene</strong> — 感知環境</li>
  <li><strong>Think it Through</strong> — 規劃策略</li>
  <li><strong>Take Action</strong> — 執行行動</li>
  <li><strong>Learn and Get Better</strong> — 從結果中學習與優化</li>
</ol>

<p>這五個步驟，構成了一個完整 Agent 的能力。</p>

<p>我覺得這也回答到，一個完整的Agent能力是複雜的，各式各樣的AGENT設計模式（ReAct、Parallel、Route）都是為了讓LLM疊加上這些能力。</p>

<h2 id="我的場景真的需要完整的-agent-能力嗎">我的場景，真的需要完整的 Agent 能力嗎？</h2>

<p>有了清晰的定義之後，下一個問題就是：<strong>使用場景是否需要這麼完整的能力？</strong></p>

<p>面對客戶需求，我通常會先問自己幾個問題：</p>

<ol>
  <li>任務需要使用者主動提供，還是 Agent 必須能自主感知環境？</li>
  <li>情境是固定的，還是動態變化的？</li>
  <li>是否需要從錯誤中學習並持續優化？</li>
</ol>

<p>以 <strong>Parallel pattern</strong> 為例，它適合在情境固定、任務較為複雜的場景下使用。在這種情況下，Agent 不需要太強的環境感知能力，因為任務已被預先分配好，Agent 只需專注完成各自的子任務，不需要思考整體流程或應對情境變化。</p>

<p>相反，若場景是<strong>動態且不可預測的</strong>，<strong>ReAct pattern</strong> 則更為適合。Agent 需要持續感知環境的變化，根據新的資訊調整行動策略，這對環境感知與迭代優化的能力要求都更高。</p>

<p>各種Pattern的設計沒有好壞，只有適不適合的問題，選擇前一定要先釐清可以接受哪些，以及不能接受哪些，這也帶到我認為在設計 Agent 的時候，無法避開的一個重要議題：<strong>AI Agent 的 Iron Triangle</strong>。</p>

<h2 id="ai-agent-的-iron-triangle">AI Agent 的 Iron Triangle</h2>

<p>設計 AI Agent 時，我認為同樣存在一個類似的 Iron Triangle，只是三個頂點換成了：<strong>Accuracy（準確性）、Latency（延遲）、Cost（成本）</strong>。</p>

<p><img src="https://static.jimmyblog.site/2026-04-26-what-is-ai-agents/AI_AGENT_IRON_TRIANGLE_2.webp" alt="AI_AGENT_IRON_TRIANGLE" /></p>

<p>三者無法兼得，設計前必須先釐清你最在乎哪個維度。</p>

<p>這也是我認為基於SLM（Single Large Model）Agent Flow 設計仍然具備研究價值的原因，因為在被各種強大的大型語言模型寵溺的當下，可能讓我們忽略了，<strong>在某些場景下，簡單的 SLM Agent Flow 就足夠了</strong>，不需要為了追求更高的準確性而投入更多成本。</p>

<h2 id="爆紅的openclaw">爆紅的OpenClaw</h2>

<p>2026年初，OpenClaw 的爆紅，也讓我在和其他公司或客戶交流時，很常被問到，我怎麼看待 OpenClaw 的設計，以及它在 Agent 設計上的啟示。OpenClaw 的成功，主要在他在設計上直接讓 Agent 具備操作系統的能力，不再是單純的串接各種API，而是操作電腦去達成任務。但模型依舊是核心，如何使用SLM也達到不錯的效果，或許會是下一個Agent設計的挑戰。</p>

<p>我很喜歡 Andrej Karpathy 將 LLM 應用比擬為作業系統的說法。</p>

<p><img src="https://static.jimmyblog.site/2026-04-26-what-is-ai-agents/LLMOS.webp" alt="LLMOS" /></p>

<p>這也啟發我用這個框架去解釋LLM 和 AI Agent 的關係：</p>

<p><img src="https://static.jimmyblog.site/2026-04-26-what-is-ai-agents/AI_AGENT_COMPUTER_SYSTEM_3.webp" alt="AI_AGENT_COMPUTER_SYSTEM" /></p>

<table>
  <thead>
    <tr>
      <th>AI 概念</th>
      <th>零件</th>
      <th>原因</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>LLM</td>
      <td>CPU</td>
      <td>核心運算、推理、理解語言的地方</td>
    </tr>
    <tr>
      <td>HARNESS</td>
      <td>主機板</td>
      <td>把所有零件串在一起，協調各種訊號流動</td>
    </tr>
    <tr>
      <td>Tools</td>
      <td>擴充插槽 / PCIe</td>
      <td>讓 Agent 能接上外部能力（搜尋、執行程式等）</td>
    </tr>
    <tr>
      <td>Memory</td>
      <td>RAM</td>
      <td>短期記憶，處理當前任務的上下文</td>
    </tr>
    <tr>
      <td>Vector DB / DB</td>
      <td>硬碟</td>
      <td>長期記憶，需要時再讀取</td>
    </tr>
    <tr>
      <td>System Prompt</td>
      <td>BIOS 設定</td>
      <td>開機前就決定好行為模式</td>
    </tr>
  </tbody>
</table>

<h2 id="參考資料">參考資料</h2>
<ul>
  <li><a href="https://irp.cdn-website.com/ca79032a/files/uploaded/Agentic-Design-Patterns.pdf">Agentic Design Patterns — Antonio Gulli</a></li>
  <li><a href="https://rlancemartin.github.io/2026/01/09/agent_design/">Agentic Design Patterns</a></li>
  <li><a href="https://docs.langchain.com/oss/python/langchain/multi-agent">Multi-agent — LangChain</a></li>
  <li><a href="https://docs.cloud.google.com/architecture/choose-design-pattern-agentic-ai-system">Choose a design pattern for your agentic AI system — Google Cloud</a></li>
  <li><a href="https://www.youtube.com/watch?v=LCEmiRjPEtQ&amp;t=620s">Andrej Karpathy: Software Is Changing (Again)</a></li>
</ul>]]></content><author><name></name></author><category term="AI Agents" /><summary type="html"><![CDATA[最近在和不同的公司交流，聊到 AI 應用時，話題常常圍繞著如何為公司或客戶設計一套屬於他們的 Agent Flow，或者說 Agent Design Pattern——可能是 ReAct pattern、Parallel pattern……]]></summary></entry><entry xml:lang="en"><title type="html">What Are Claude Code’s Subagents and Skills?</title><link href="https://jimmyblog.site/en/2025/12/14/what-is-subagents-and-skills/" rel="alternate" type="text/html" title="What Are Claude Code’s Subagents and Skills?" /><published>2025-12-14T07:00:00+00:00</published><updated>2025-12-14T07:00:00+00:00</updated><id>https://jimmyblog.site/en/2025/12/14/what-is-subagents-and-skills</id><content type="html" xml:base="https://jimmyblog.site/en/2025/12/14/what-is-subagents-and-skills/"><![CDATA[<h1 id="the-breakneck-pace-of-ai-evolution">The Breakneck Pace of AI Evolution</h1>

<p>It’s been nearly six months since I last wrote about Claude Code Hooks, and the progress in large language models during this period has been nothing short of staggering. We’ve seen Gemini 3.0, the new IDE tool <a href="https://antigravity.google/">Antigravity</a>, Claude Opus 4.5, and most recently GPT-5.2—all within just a few months. The sheer speed of iteration in the AI space is mind-blowing. It’s got me thinking about whether I should invest more time into leveraging AI tools to streamline my workflow and automate more of my daily tasks.</p>

<h1 id="how-claude-code-has-evolved-over-the-past-six-months">How Claude Code Has Evolved Over the Past Six Months</h1>

<p>Claude Code has come a long way during this time. Starting from basic functionality, it can now orchestrate <a href="https://code.claude.com/docs/en/sub-agents">Subagents</a> to tackle complex tasks collaboratively. The ecosystem has expanded with <a href="https://code.claude.com/docs/en/plugins">plugins</a>, a <a href="https://code.claude.com/docs/en/plugin-marketplaces">marketplace</a>, and other features that make extending functionality much more accessible. There’s also the introduction of <a href="https://code.claude.com/docs/en/skills">Skills</a>, which let users define their own workflows and have Claude Code execute tasks according to these predefined procedures. These advancements have made Claude Code significantly more powerful and versatile across various use cases.</p>

<h2 id="what-are-subagents">What Are Subagents?</h2>

<p>According to Claude Code’s official documentation, Subagents are specialized agents designed to handle specific tasks. In my view, their primary purpose is to solve the problem of overly long context windows in a single conversation, which can hamper the model’s effectiveness. By breaking down complex tasks into subtasks handled by different Subagents, you reduce the burden on any single conversation while allowing each Subagent to focus on its specific domain—ultimately improving both efficiency and accuracy.</p>

<h2 id="use-cases-for-subagents">Use Cases for Subagents</h2>

<p>I think this feature shines brightest when you need to orchestrate multiple MCP tools. If you’ve used VS Code Copilot extensively, you probably know that loading too many MCP tools in a single project can eat up a lot of context, making it harder for the model to effectively utilize them.</p>

<p>Defining a Subagent is straightforward—just create a <code class="language-plaintext highlighter-rouge">.md</code> file like this:</p>

<div class="language-markdown highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nn">---</span>
<span class="na">name</span><span class="pi">:</span> <span class="s">your-sub-agent-name</span>
<span class="na">description</span><span class="pi">:</span> <span class="s">Description of when this subagent should be invoked</span>
<span class="na">tools</span><span class="pi">:</span> <span class="s">tool1, tool2, tool3</span>  <span class="c1"># Optional - inherits all tools if omitted</span>
<span class="na">model</span><span class="pi">:</span> <span class="s">sonnet</span>  <span class="c1"># Optional - specify model alias or 'inherit'</span>
<span class="nn">---</span>

Your subagent's system prompt goes here. This can be multiple paragraphs
and should clearly define the subagent's role, capabilities, and approach
to solving problems.

Include specific instructions, best practices, and any constraints
the subagent should follow.
<span class="p">
---
</span></code></pre></div></div>

<h2 id="what-are-skills">What Are Skills?</h2>

<p>Here’s how Anthropic officially defines Skills:</p>

<blockquote>
  <p>Claude is powerful, but real work requires procedural knowledge and organizational context. Introducing Agent Skills, a new way to build specialized agents using files and folders.</p>
</blockquote>

<p>Essentially, Skills help Claude Code better understand your workflows and organizational context, enabling it to complete tasks more effectively.</p>

<p><img src="https://static.jimmyblog.site/2025-12-14-what-is-subagents-and-skills/agent_skill.webp" alt="Agent Skill" /></p>

<p>Consider this scenario: you’ve connected multiple MCP tools to Claude Code, but you really only need it to complete a specific task. Let’s say you want the agent to query data from a PostgreSQL database, format it into a report, and update it in Notion. Throughout this entire workflow, you might only use a handful of tools from a much larger toolkit. By defining the process steps through a Skill, you reduce the cognitive load on the LLM—it doesn’t have to figure out which tools to use because you’ve already specified that, allowing it to focus on the task itself.</p>

<p>This is quite similar to what many people do during Vibe Coding, where they predefine certain workflows or steps for the agent to follow. The Skill concept works the same way, except it establishes a kind of “standardized workflow format” that’s easier to extend or port to other CLI tools down the line.</p>

<blockquote>
  <p>Codex CLI now supports Skills too: <a href="https://developers.openai.com/codex/skills/">Codex Agent Skills</a></p>
</blockquote>

<h1 id="dont-build-agents-build-skills-instead">Don’t Build Agents, Build Skills Instead</h1>

<p>A few days ago, while browsing YouTube, I came across a video titled <a href="https://www.youtube.com/watch?v=CEvIs9y1uog">Don’t Build Agents, Build Skills Instead</a>. It made some compelling points:</p>

<blockquote>
  <p>Code is all you need.</p>
</blockquote>

<p>And:</p>

<blockquote>
  <p>Code is the universal interface</p>
</blockquote>

<p>This got me thinking—could we treat CLI tools like Claude Code as general-purpose agents that help with generating reports and organizing data, rather than just writing code? Or maybe we should start viewing these procedural Skills as apps, with the Agent serving as the OS that helps us run them. After all, when it comes to integrating with third-party systems, any LLM web app—whether Gemini, ChatGPT, or others—just isn’t as convenient as working in a CLI environment.</p>

<p><img src="https://static.jimmyblog.site/2025-12-14-what-is-subagents-and-skills/Skill.webp" alt="Skill as an App" /></p>

<h1 id="final-thoughts">Final Thoughts</h1>

<p>In summary, the introduction of Subagents and Skills opens up new possibilities for CLI tools and enables exploration of more real-world applications. That said, from a pure Vibe Coding tool perspective, I still prefer Cursor at the moment. Besides being significantly faster than VS Code Copilot, it offers a direct <a href="https://cursor.com/docs/agent/browser">browser element selection feature</a> for frontend development that makes interaction much smoother. The pricing is also more flexible—unlike Claude Code Pro and Max, which lack a middle-ground option. When I get the chance, I’ll share more thoughts on my experience with Vibe Coding tools.</p>]]></content><author><name></name></author><category term="Claude Code" /><summary type="html"><![CDATA[The Breakneck Pace of AI Evolution]]></summary></entry><entry xml:lang="zh"><title type="html">什麼是 Claude Code 的 Subagents 與 Skills？</title><link href="https://jimmyblog.site/zh/2025/12/14/what-is-subagents-and-skills/" rel="alternate" type="text/html" title="什麼是 Claude Code 的 Subagents 與 Skills？" /><published>2025-12-14T07:00:00+00:00</published><updated>2025-12-14T07:00:00+00:00</updated><id>https://jimmyblog.site/zh/2025/12/14/what-is-subagents-and-skills</id><content type="html" xml:base="https://jimmyblog.site/zh/2025/12/14/what-is-subagents-and-skills/"><![CDATA[<h1 id="ai-迭代神速">AI 迭代神速</h1>

<p>距離上一次介紹 Claude Code Hooks 已經過了將近半年時間，這段期間內無論是大型語言模型的進步，包含 Gemini 3.0，新的IDE工具 <a href="https://antigravity.google/">Antigravity</a>、Claude Opus 4.5 或是最近出來的 GPT-5.2，時間也才短短經歷了幾個月而已。這些模型的進步速度之快，讓人不禁感嘆 AI 領域的迭代速度真是神速。也開始讓我思考，是不是要投入更多時間來研究如何讓 AI 工具更有效率地協助我的工作，或是自動化更多我的日常任務。</p>

<h1 id="claude-code-在這半年的進化">Claude Code 在這半年的進化</h1>
<p>在這段期間內，Claude Code 也有了不少進化。從最初的基本功能，到目前可以規劃 <a href="https://code.claude.com/docs/zh-TW/sub-agents">Subagents</a>，共同處理複雜任務，也延伸了 <a href="https://code.claude.com/docs/zh-TW/plugins">plugin</a> 的概念、<a href="https://code.claude.com/docs/zh-TW/plugin-marketplaces">marketplace</a> 等生態系，讓使用者可以更方便地擴展功能。另外還有引入 <a href="https://code.claude.com/docs/zh-TW/skills">Skill</a> 的概念，讓使用者可以定義自己的 workflow，並讓 Claude Code 根據這些技能來執行任務。這些進化讓 Claude Code 變得更加強大，也更適合用於各種不同的應用場景。</p>

<h2 id="什麼是-subagents">什麼是 Subagents？</h2>

<p>Subagents 在 Claude Code 官方的 Docs 中被定義為專門處理特定任務的 Agents，我覺得主要目的就是解決單一對話的 Context 過長導致模型無法有效處理的問題。透過 Subagents，可以將複雜任務拆解成多個子任務，並由不同的 Subagents 來處理，這樣不僅可以減少單一對話的負擔，也能讓每個 Subagent 專注於特定的任務，提高整體的效率和準確性。</p>

<h2 id="subagents-的應用場景">Subagents 的應用場景</h2>

<p>這個功能我認為最適合運用在需要調度 MCP 工具的情境，常使用 VS Code Copilot 的人應該會知道，當同一專案調度過多的 MCP 工具時，可能會占用過多的 context，導致模型無法有效利用這些工具來完成任務。</p>

<p>撰寫方式也很容易，只需要透過撰寫一份 <code class="language-plaintext highlighter-rouge">.md</code> 檔案如下，就可以定義一個 Subagent，包含可用的工具及模型等資訊：</p>

<div class="language-markdown highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nn">---</span>
<span class="na">name</span><span class="pi">:</span> <span class="s">your-sub-agent-name</span>
<span class="na">description</span><span class="pi">:</span> <span class="s">Description of when this subagent should be invoked</span>
<span class="na">tools</span><span class="pi">:</span> <span class="s">tool1, tool2, tool3</span>  <span class="c1"># Optional - inherits all tools if omitted</span>
<span class="na">model</span><span class="pi">:</span> <span class="s">sonnet</span>  <span class="c1"># Optional - specify model alias or 'inherit'</span>
<span class="nn">---</span>

Your subagent's system prompt goes here. This can be multiple paragraphs
and should clearly define the subagent's role, capabilities, and approach
to solving problems.

Include specific instructions, best practices, and any constraints
the subagent should follow.
<span class="p">
---
</span></code></pre></div></div>

<h2 id="什麼是-skill">什麼是 Skill？</h2>

<p>從 Anthropic 官方對於 Skill 的定義來看：</p>

<blockquote>
  <p>Claude is powerful, but real work requires procedural knowledge and organizational context. Introducing Agent Skills, a new way to build specialized agents using files and folders.</p>
</blockquote>

<p>其實可以理解，Skill 就是為了幫助 Claude Code 更好地理解使用者的工作流程和組織背景，從而更有效地完成任務。</p>

<p><img src="https://static.jimmyblog.site/2025-12-14-what-is-subagents-and-skills/agent_skill.webp" alt="Agent Skill" /></p>

<p>可以想像情境，假設我們在 Claude Code 同時串接了多項 MCP 工具，但是其實只是想要讓 Claude Code 幫忙完成特定的任務。隨機的舉例，假設是希望 Agent 到 PostgreSQL 資料庫中查詢特定的資料，並將資料整理成報表，更新到 Notion 中。在這整個流程中，可能只會調動到龐大工具中的幾項工具，透過 Skill 定義好步驟流程，可以減少讓 LLM 去思考到底要調用哪些工具，反而可以專注在任務本身。</p>

<p>其實就滿類似很多人在 Vibe Coding 時會預先定義一些流程或是步驟，來讓 Agent 遵守步驟完成任務，Skill 的概念也是類似的。只是像是更早提出這個概念，有點像是提出一個「流程化的標準」，方便日後擴展，或是沿用到其他CLI工具中。</p>

<blockquote>
  <p>現在 Codex CLI 也支援Skills：<a href="https://developers.openai.com/codex/skills/">Codex Agent Skills</a></p>
</blockquote>

<h1 id="dont-build-agents-build-skills-instead">Don’t Build Agents, Build Skills Instead</h1>

<p>前幾天在瀏覽 YouTube 時，看到一支影片，標題是 <a href="https://www.youtube.com/watch?v=CEvIs9y1uog">Don’t Build Agents, Build Skills Instead</a>，其中提到：</p>

<blockquote>
  <p>Code is all you need.</p>
</blockquote>

<p>以及</p>

<blockquote>
  <p>Code is the universal interface</p>
</blockquote>

<p>其實也讓我思考，我們是否也可以把 Claude Code 這類 CLI 工具，也當作 General Purpose Agent，他可以幫忙產報表、整理資料，而不是僅限於程式碼生成。又或是開始把這些流程化的 Skill，視為一種 APP，而 Agent 只是 OS，來協助我們執行這些 APP。因為其實對於使用任何一項LLM Web App，無論是Gemini，ChatGPT…，在串接第三方的系統時，其實都不如在CLI環境中來得方便。</p>

<p><img src="https://static.jimmyblog.site/2025-12-14-what-is-subagents-and-skills/Skill.webp" alt="Skill as an App" /></p>

<h1 id="結語">結語</h1>
<p>總結來說，Subagents 與 Skills 的引入，讓CLI工具有更多的可能性，也探索更多可能的生活場景，但如果以Vibe Coding工具的角度來看，我目前還是比較喜歡使用Cursor，除了運行時間上遠快於VS Code Copilot以外，在前端開發上，也提供直接<a href="https://cursor.com/docs/agent/browser">點選網頁元素的方式來完成任務交互</a>，在價錢上面也有比較多種選擇，不像是 Claude Code Pro 以及 Max 之間沒有可選的中間方案。之後有時間的話，也會再來分享更多關於VibeCoding工具的使用心得。</p>]]></content><author><name></name></author><category term="Claude Code" /><summary type="html"><![CDATA[AI 迭代神速]]></summary></entry><entry xml:lang="en"><title type="html">How to Send Telegram Notifications with Claude Code Hooks — Never Wait for AI to Finish Again!</title><link href="https://jimmyblog.site/en/2025/07/05/claude-code-hooks/" rel="alternate" type="text/html" title="How to Send Telegram Notifications with Claude Code Hooks — Never Wait for AI to Finish Again!" /><published>2025-07-05T07:00:00+00:00</published><updated>2025-07-05T07:00:00+00:00</updated><id>https://jimmyblog.site/en/2025/07/05/claude-code-hooks</id><content type="html" xml:base="https://jimmyblog.site/en/2025/07/05/claude-code-hooks/"><![CDATA[<h1 id="introduction-to-claude-code-hooks">Introduction to Claude Code Hooks</h1>
<p>Claude Code Hooks is an event-driven automation mechanism that allows you to automatically execute specified shell commands before or after Claude Code performs certain operations.</p>

<p>When using Claude Code, you often want to complete a custom task after a specific operation finishes, before continuing with subsequent tasks.</p>

<p>While you can achieve this with well-crafted prompts before starting a session, sometimes we want these custom tasks to be rigorous and not rely on the LLM to make decisions. This is where Claude Code Hooks comes in handy.</p>

<hr />

<h1 id="common-use-cases-for-claude-code-hooks">Common Use Cases for Claude Code Hooks:</h1>

<table>
  <thead>
    <tr>
      <th>Feature</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>Notifications</td>
      <td>Customize alerts when Claude Code is waiting for your input or approval</td>
    </tr>
    <tr>
      <td>Auto-formatting</td>
      <td>Automatically run prettier after each file edit</td>
    </tr>
    <tr>
      <td>Logging</td>
      <td>Track and record all executed commands for auditing or debugging</td>
    </tr>
    <tr>
      <td>Auto-feedback</td>
      <td>Automatically provide guidance when Claude Code generates code that doesn’t comply with library standards</td>
    </tr>
    <tr>
      <td>Custom Permissions</td>
      <td>Block modifications to production files or sensitive directories</td>
    </tr>
  </tbody>
</table>

<hr />

<p>Claude Code Hooks events are categorized into <strong>PreToolUse</strong>, <strong>PostToolUse</strong>, <strong>Notification</strong>, <strong>Stop</strong>, <strong>SubagentStop</strong>, and more.</p>

<p>Users can configure which scenarios should trigger hooks.</p>

<p>For example:</p>

<p>In the PostToolUse scenario, when <strong>Claude Code</strong> executes Write, Edit, or MultiEdit operations, the corresponding hooks will be triggered.</p>

<div class="language-json highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="p">{</span><span class="w">
  </span><span class="nl">"hooks"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w">
    </span><span class="nl">"PostToolUse"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="w">
      </span><span class="p">{</span><span class="w">
        </span><span class="nl">"matcher"</span><span class="p">:</span><span class="w"> </span><span class="s2">"Write|Edit|MultiEdit"</span><span class="p">,</span><span class="w">
        </span><span class="nl">"hooks"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="w">
          </span><span class="p">{</span><span class="w">
            </span><span class="nl">"type"</span><span class="p">:</span><span class="w"> </span><span class="s2">"command"</span><span class="p">,</span><span class="w">
            </span><span class="nl">"command"</span><span class="p">:</span><span class="w"> </span><span class="s2">"/home/user/scripts/format-code.sh"</span><span class="w">
          </span><span class="p">}</span><span class="w">
        </span><span class="p">]</span><span class="w">
      </span><span class="p">}</span><span class="w">
    </span><span class="p">]</span><span class="w">
  </span><span class="p">}</span><span class="w">
</span><span class="p">}</span><span class="w">
</span></code></pre></div></div>
<hr />

<h1 id="how-to-send-telegram-notifications-with-claude-code-hooks">How to Send Telegram Notifications with Claude Code Hooks</h1>

<p>Let’s create a simple example where Claude Code automatically sends a Telegram notification when it’s waiting for your input.</p>

<p>First, write a simple shell script that sends Telegram notifications.</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c">#!/bin/bash</span>

<span class="c"># Script for sending Telegram notifications</span>
<span class="nv">TELEGRAM_SCRIPT</span><span class="o">=</span><span class="s2">"/home/jimmy/script/telegram-notify.sh"</span>

<span class="c"># I want the notifications to look nice, so I wrote a format_notification function to handle the notification format</span>
format_notification<span class="o">()</span> <span class="o">{</span>
    <span class="nb">local </span><span class="nv">hook_data</span><span class="o">=</span><span class="s2">"</span><span class="nv">$1</span><span class="s2">"</span>

    <span class="c"># Check if jq is available</span>
    <span class="k">if</span> <span class="o">!</span> <span class="nb">command</span> <span class="nt">-v</span> jq <span class="o">&gt;</span>/dev/null 2&gt;&amp;1<span class="p">;</span> <span class="k">then
        </span><span class="nb">echo</span> <span class="s2">"🤖 Claude Notification
💬 jq not available - raw notification"</span> | <span class="s2">"</span><span class="nv">$TELEGRAM_SCRIPT</span><span class="s2">"</span>
        <span class="k">return </span>0
    <span class="k">fi</span>

    <span class="c"># Extract message and hook_event_name from hook input</span>
    <span class="nb">local </span>message
    <span class="nb">local </span>hook_event_name

    <span class="nv">message</span><span class="o">=</span><span class="si">$(</span><span class="nb">echo</span> <span class="s2">"</span><span class="nv">$hook_data</span><span class="s2">"</span> | jq <span class="nt">-r</span> <span class="s1">'.message // "No message"'</span> 2&gt;/dev/null<span class="si">)</span>
    <span class="nv">hook_event_name</span><span class="o">=</span><span class="si">$(</span><span class="nb">echo</span> <span class="s2">"</span><span class="nv">$hook_data</span><span class="s2">"</span> | jq <span class="nt">-r</span> <span class="s1">'.hook_event_name // "Unknown"'</span> 2&gt;/dev/null<span class="si">)</span>


    <span class="nb">local </span><span class="nv">formatted_message</span><span class="o">=</span><span class="s2">"🤖 &lt;b&gt;Claude Notification&lt;/b&gt;
💬 </span><span class="nv">$message</span><span class="s2">"</span>

    <span class="c"># Send Telegram notification</span>
    <span class="nb">echo</span> <span class="s2">"</span><span class="nv">$formatted_message</span><span class="s2">"</span> | <span class="s2">"</span><span class="nv">$TELEGRAM_SCRIPT</span><span class="s2">"</span>

    <span class="k">return</span> <span class="nv">$?</span>
<span class="o">}</span>

</code></pre></div></div>
<p>Next, configure hooks in Claude Code. After entering the Claude Code CLI interface, use <strong>/hooks</strong> to enter the hooks configuration screen, which looks like this:
<img src="https://static.jimmyblog.site/2025-07-05-claude-code-hooks/claude_code_hooks.webp" alt="Claude Code Hooks Interface" /></p>

<p>Go to the Notification field and click “Add new hook”, enter the path to the shell script we just wrote, and also adjust whether this hook is a project setting or a global user setting.
At this point, your settings.json will show your hooks configuration as follows:</p>

<div class="language-json highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="p">{</span><span class="w">
  </span><span class="nl">"hooks"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w">
    </span><span class="nl">"Notification"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="w">
      </span><span class="p">{</span><span class="w">
        </span><span class="nl">"matcher"</span><span class="p">:</span><span class="w"> </span><span class="s2">""</span><span class="p">,</span><span class="w">
        </span><span class="nl">"hooks"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="w">
          </span><span class="p">{</span><span class="w">
            </span><span class="nl">"type"</span><span class="p">:</span><span class="w"> </span><span class="s2">"command"</span><span class="p">,</span><span class="w">
            </span><span class="nl">"command"</span><span class="p">:</span><span class="w"> </span><span class="s2">"/home/jimmy/script/claude-notification-message.sh"</span><span class="w">
          </span><span class="p">}</span><span class="w">
        </span><span class="p">]</span><span class="w">
      </span><span class="p">}</span><span class="w">
    </span><span class="p">]</span><span class="w">
  </span><span class="p">}</span><span class="w">
</span><span class="p">}</span><span class="w">
</span></code></pre></div></div>

<p>Now you can start testing. I often switch to other windows while Claude Code is running.</p>

<p>I frequently encounter situations where it’s waiting for my approval, but I don’t notice. This feature helps remind me.</p>

<p>Here’s an example where I ask Claude Code to execute a Bash command to create a folder:</p>

<p>When it triggers a Notification, it automatically sends me a Telegram notification.</p>

<p>Never forget that you asked Claude Code to do something again! 😂</p>

<p><img src="https://static.jimmyblog.site/2025-07-05-claude-code-hooks/claude_code_hooks_demo_2.webp" alt="Claude Code Hooks demo" /></p>

<hr />

<h1 id="conclusion">Conclusion</h1>
<p>When configuring Claude Code Hooks, you can also use Hook Output to determine the logic for successful and failed hook executions, using Exit Code or JSON Output.
Additionally, matchers can be configured for MCP tool usage scenarios, making it convenient to execute planned hooks when triggering specific MCP tools. By setting up comprehensive hooks, you can make Claude Code usage more rigorous and reduce the time spent checking for errors afterward.</p>

<h1 id="references">References</h1>

<p><a href="https://docs.anthropic.com/en/docs/claude-code/hooks">Claude Code Hooks Official Documentation</a></p>]]></content><author><name></name></author><category term="Claude Code" /><summary type="html"><![CDATA[Introduction to Claude Code Hooks Claude Code Hooks is an event-driven automation mechanism that allows you to automatically execute specified shell commands before or after Claude Code performs certain operations.]]></summary></entry><entry xml:lang="zh"><title type="html">如何用 Claude Code Hooks 寄送 Telegram 通知，再也不用等待 AI 完成任務！</title><link href="https://jimmyblog.site/zh/2025/07/05/claude-code-hooks/" rel="alternate" type="text/html" title="如何用 Claude Code Hooks 寄送 Telegram 通知，再也不用等待 AI 完成任務！" /><published>2025-07-05T07:00:00+00:00</published><updated>2025-07-05T07:00:00+00:00</updated><id>https://jimmyblog.site/zh/2025/07/05/claude-code-hooks</id><content type="html" xml:base="https://jimmyblog.site/zh/2025/07/05/claude-code-hooks/"><![CDATA[<h1 id="claude-code-hooks-介紹">Claude Code Hooks 介紹</h1>
<p>Claude Code Hooks 是一種 事件驅動的自動化機制，允許你在 Claude Code 執行某些操作之前或之後，自動執行你指定的 shell 命令。</p>

<p>在使用 Claude code時，常常會希望執行完特定任務時，可以先完成某個使用者自訂的任務，再繼續延續執行後續的任務。</p>

<p>雖然這都可以在開啟session前用足夠好的prompt要求model執行，但有時候我們希望這些自訂任務可以足夠嚴謹，不仰賴LLM來做決定，這就是Claude Code Hooks 的用武之地。</p>

<hr />

<h1 id="claude-code-hooks-常見的使用情境分為以下幾種">Claude Code Hooks 常見的使用情境分為以下幾種：</h1>

<table>
  <thead>
    <tr>
      <th>功能項目</th>
      <th>說明</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>通知</td>
      <td>自訂當 Claude Code 等待你的輸入或執行許可時的提醒方式</td>
    </tr>
    <tr>
      <td>自動格式化</td>
      <td>每次編輯檔案後，自動執行 prettier</td>
    </tr>
    <tr>
      <td>日誌記錄</td>
      <td>追蹤並統計所有執行過的指令，方便稽核或除錯</td>
    </tr>
    <tr>
      <td>自動回饋</td>
      <td>當 Claude Code 產生不符合程式庫規範的程式碼時，自動提供指導</td>
    </tr>
    <tr>
      <td>自訂權限</td>
      <td>阻擋對生產環境檔案或敏感目錄的修改行為</td>
    </tr>
  </tbody>
</table>

<hr />

<p>Claude Code Hooks 的事件驅動分為 <strong>PreToolUse</strong>、<strong>PostToolUse</strong>、<strong>Notification</strong>、<strong>Stop</strong>、<strong>SubagentStop</strong> 等等情境</p>

<p>使用者可以調整決定什麼情境才要驅動hooks</p>

<p>舉例:</p>

<p>在PostToolUse的情境下，當 <strong>Claude Code</strong> 執行了Write、Edit或MultiEdit等操作時，就會觸發相對應的hooks。</p>

<div class="language-json highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="p">{</span><span class="w">
  </span><span class="nl">"hooks"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w">
    </span><span class="nl">"PostToolUse"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="w">
      </span><span class="p">{</span><span class="w">
        </span><span class="nl">"matcher"</span><span class="p">:</span><span class="w"> </span><span class="s2">"Write|Edit|MultiEdit"</span><span class="p">,</span><span class="w">
        </span><span class="nl">"hooks"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="w">
          </span><span class="p">{</span><span class="w">
            </span><span class="nl">"type"</span><span class="p">:</span><span class="w"> </span><span class="s2">"command"</span><span class="p">,</span><span class="w">
            </span><span class="nl">"command"</span><span class="p">:</span><span class="w"> </span><span class="s2">"/home/user/scripts/format-code.sh"</span><span class="w">
          </span><span class="p">}</span><span class="w">
        </span><span class="p">]</span><span class="w">
      </span><span class="p">}</span><span class="w">
    </span><span class="p">]</span><span class="w">
  </span><span class="p">}</span><span class="w">
</span><span class="p">}</span><span class="w">
</span></code></pre></div></div>
<hr />

<h1 id="如何使用-claude-code-hooks-寄送-telegram-通知">如何使用 Claude Code Hooks 寄送 Telegram 通知</h1>

<p>接下來開始時做一個簡單的範例，當 Claude Code 執行需要等待你的輸入時，會自動寄送 Telegram 通知。</p>

<p>首先先寫一隻簡單的 shell script，這個 script 會寄送 Telegram 通知。</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c">#!/bin/bash</span>

<span class="c"># 寄送 Telegram 通知的腳本</span>
<span class="nv">TELEGRAM_SCRIPT</span><span class="o">=</span><span class="s2">"/home/jimmy/script/telegram-notify.sh"</span>

<span class="c"># 因為我希望寄送的通知可以稍微美觀點，所以另外寫一個format_notification 函式來處理通知格式</span>
format_notification<span class="o">()</span> <span class="o">{</span>
    <span class="nb">local </span><span class="nv">hook_data</span><span class="o">=</span><span class="s2">"</span><span class="nv">$1</span><span class="s2">"</span>
    
    <span class="c"># Check if jq is available</span>
    <span class="k">if</span> <span class="o">!</span> <span class="nb">command</span> <span class="nt">-v</span> jq <span class="o">&gt;</span>/dev/null 2&gt;&amp;1<span class="p">;</span> <span class="k">then
        </span><span class="nb">echo</span> <span class="s2">"🤖 Claude Notification
💬 jq not available - raw notification"</span> | <span class="s2">"</span><span class="nv">$TELEGRAM_SCRIPT</span><span class="s2">"</span>
        <span class="k">return </span>0
    <span class="k">fi</span>
    
    <span class="c"># 抓取hook input 訊息中的 message 和 hook_event_name</span>
    <span class="nb">local </span>message
    <span class="nb">local </span>hook_event_name
    
    <span class="nv">message</span><span class="o">=</span><span class="si">$(</span><span class="nb">echo</span> <span class="s2">"</span><span class="nv">$hook_data</span><span class="s2">"</span> | jq <span class="nt">-r</span> <span class="s1">'.message // "No message"'</span> 2&gt;/dev/null<span class="si">)</span>
    <span class="nv">hook_event_name</span><span class="o">=</span><span class="si">$(</span><span class="nb">echo</span> <span class="s2">"</span><span class="nv">$hook_data</span><span class="s2">"</span> | jq <span class="nt">-r</span> <span class="s1">'.hook_event_name // "Unknown"'</span> 2&gt;/dev/null<span class="si">)</span>
    

    <span class="nb">local </span><span class="nv">formatted_message</span><span class="o">=</span><span class="s2">"🤖 &lt;b&gt;Claude Notification&lt;/b&gt;
💬 </span><span class="nv">$message</span><span class="s2">"</span>
    
    <span class="c"># 寄送 Telegram 通知</span>
    <span class="nb">echo</span> <span class="s2">"</span><span class="nv">$formatted_message</span><span class="s2">"</span> | <span class="s2">"</span><span class="nv">$TELEGRAM_SCRIPT</span><span class="s2">"</span>
    
    <span class="k">return</span> <span class="nv">$?</span>
<span class="o">}</span>

</code></pre></div></div>
<p>接下來到claude code中設定hooks，進入claude code cli介面後，使用 <strong>/hooks</strong> 進入hooks設定介面，會出現以下畫面：
<img src="https://static.jimmyblog.site/2025-07-05-claude-code-hooks/claude_code_hooks.webp" alt="Claude Code Hooks的畫面" /></p>

<p>進入在Notification的欄位中Add new hook，輸入我們剛剛寫好的 shell script 路徑，也一起調整這個hooks為專案設定還是使用者全域設定。
這時候的settings.json會顯示你的hooks設定如下：</p>

<div class="language-json highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="p">{</span><span class="w">
  </span><span class="nl">"hooks"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w">
    </span><span class="nl">"Notification"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="w">
      </span><span class="p">{</span><span class="w">
        </span><span class="nl">"matcher"</span><span class="p">:</span><span class="w"> </span><span class="s2">""</span><span class="p">,</span><span class="w">
        </span><span class="nl">"hooks"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="w">
          </span><span class="p">{</span><span class="w">
            </span><span class="nl">"type"</span><span class="p">:</span><span class="w"> </span><span class="s2">"command"</span><span class="p">,</span><span class="w">
            </span><span class="nl">"command"</span><span class="p">:</span><span class="w"> </span><span class="s2">"/home/jimmy/script/claude-notification-message.sh"</span><span class="w">
          </span><span class="p">}</span><span class="w">
        </span><span class="p">]</span><span class="w">
      </span><span class="p">}</span><span class="w">
    </span><span class="p">]</span><span class="w">
  </span><span class="p">}</span><span class="w">
</span><span class="p">}</span><span class="w">
</span></code></pre></div></div>

<p>接下來就可以開始測試了，我自己很常在 Claude Code 執行時跳到其他視窗</p>

<p>很常遇到，在等待我approve，我卻沒有注意到，這時候就可以透過這個功能來提醒我。</p>

<p>這邊以請Claude Code 執行Bash命令串建一個資料夾作為舉例：</p>

<p>當他觸發 Notification 的時候，會自動寄送 Telegram 通知給我</p>

<p>再也不會忘記自己有叫Claude Code 做事了！😂</p>

<p><img src="https://static.jimmyblog.site/2025-07-05-claude-code-hooks/claude_code_hooks_demo_2.webp" alt="Claude Code Hooks demo" /></p>

<hr />

<h1 id="結論">結論</h1>
<p>在設定 Claude Code Hooks 時，還可以運用Hook Output來決定執行hooks成功及失敗的對應邏輯，可以使用Exit Code或是Json Output來決定。
除此之外，matcher也可以設定在mcp tool 使用的情境，方便在觸發特定的mcp tool時，執行規劃好的hooks。透過設立好完善的hooks，可以讓
Claude Code的使用更加嚴謹，減少產生錯誤後續檢查的時間。</p>

<h1 id="參考資料">參考資料</h1>

<p><a href="https://docs.anthropic.com/en/docs/claude-code/hooks">Claude Code Hooks 官方文件</a></p>]]></content><author><name></name></author><category term="Claude Code" /><summary type="html"><![CDATA[Claude Code Hooks 介紹 Claude Code Hooks 是一種 事件驅動的自動化機制，允許你在 Claude Code 執行某些操作之前或之後，自動執行你指定的 shell 命令。]]></summary></entry><entry xml:lang="en"><title type="html">Claude Code vs Gemini CLI — Should You Switch to Gemini CLI?</title><link href="https://jimmyblog.site/en/2025/06/27/claude-code-vs-gemini-cli/" rel="alternate" type="text/html" title="Claude Code vs Gemini CLI — Should You Switch to Gemini CLI?" /><published>2025-06-27T05:00:00+00:00</published><updated>2025-06-27T05:00:00+00:00</updated><id>https://jimmyblog.site/en/2025/06/27/claude-code-vs-gemini-cli</id><content type="html" xml:base="https://jimmyblog.site/en/2025/06/27/claude-code-vs-gemini-cli/"><![CDATA[<h2 id="google-cli-release">Google CLI Release</h2>

<p>Google released Gemini CLI on June 26, 2025, joining the Agent CLI competition. Developers can use their personal Google account to log in and use Gemini CLI for free.
It provides Gemini 2.5 Pro with a 100 token context window. The model request quota can reach 60 requests per minute and up to 1,000 model executions per day — all <strong>completely free</strong>.</p>

<h2 id="comparing-claude-code-and-gemini-cli">Comparing Claude Code and Gemini CLI</h2>

<p>After initially trying Gemini CLI, I found that the usage experience isn’t very different from Claude Code.
It also supports non-interactive mode, MCP integration, and notably has native support for GoogleSearch and WebFetch functionality.
For memory management, you can use <code class="language-plaintext highlighter-rouge">--checkpoint</code> to manage memory usage and <code class="language-plaintext highlighter-rouge">-s</code> to enter sandbox mode, avoiding pollution of the local environment.</p>

<table>
  <thead>
    <tr>
      <th>Feature</th>
      <th><strong>Claude Code</strong></th>
      <th><strong>Gemini CLI</strong></th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><strong>Installation</strong></td>
      <td><code class="language-plaintext highlighter-rouge">npm install -g @anthropic-ai/claude-code</code></td>
      <td><code class="language-plaintext highlighter-rouge">npm install -g @google/gemini-cli</code></td>
    </tr>
    <tr>
      <td><strong>MCP Support</strong></td>
      <td>✅</td>
      <td>✅</td>
    </tr>
    <tr>
      <td><strong>Telemetry</strong></td>
      <td>✅</td>
      <td>✅</td>
    </tr>
    <tr>
      <td><strong>Memory Management</strong></td>
      <td>Uses <code class="language-plaintext highlighter-rouge">CLAUDE.md</code> for memory management</td>
      <td>Supports <code class="language-plaintext highlighter-rouge">--checkpointing</code> to save and restore conversation and file state</td>
    </tr>
    <tr>
      <td><strong>Security</strong></td>
      <td>Permissions configurable via <code class="language-plaintext highlighter-rouge">settings.json</code></td>
      <td>Uses <code class="language-plaintext highlighter-rouge">-s</code> flag to sandbox commands, avoiding unnecessary system changes</td>
    </tr>
    <tr>
      <td><strong>Requirements</strong></td>
      <td>Requires Claude Pro subscription</td>
      <td>Free to use, only needs Google account; 60 model requests per minute, up to 1,000 per day</td>
    </tr>
  </tbody>
</table>

<p><strong>Installing Gemini CLI</strong>:</p>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>npm <span class="nb">install</span> <span class="nt">-g</span> @google/gemini-cli
</code></pre></div></div>

<p>After successful installation, you’ll see the following message:</p>

<p><img src="https://static.jimmyblog.site/2025-06-27-claude-code-vs-gemini-cli/gemini_cli.webp" alt="Installation Success Screen" /></p>

<p>Now you can start using Gemini CLI. Here are some basic commands:</p>

<p><strong>View token usage</strong></p>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>/stats
</code></pre></div></div>

<p><strong>List available tools</strong></p>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>/tools
</code></pre></div></div>

<p><strong>Execute commands without entering interactive mode</strong></p>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>gemini <span class="nt">-p</span> <span class="s2">"your prompt"</span>
</code></pre></div></div>

<h2 id="will-claude-code-fall-from-grace">Will Claude Code Fall from Grace?</h2>

<p>For now, Claude Code remains a solid choice, especially with its integration across different platforms. Claude 4’s code comprehension and problem-solving capabilities are also outstanding. However, Gemini CLI offers a great alternative for users who don’t want to pay, and being fully open source brings more possibilities to the product.</p>]]></content><author><name></name></author><category term="Claude Code" /><category term="Gemini CLI" /><summary type="html"><![CDATA[Google CLI Release]]></summary></entry><entry xml:lang="zh"><title type="html">Claude Code vs Gemini CLI — 你該換到 Gemini CLI 嗎？</title><link href="https://jimmyblog.site/zh/2025/06/27/claude-code-vs-gemini-cli/" rel="alternate" type="text/html" title="Claude Code vs Gemini CLI — 你該換到 Gemini CLI 嗎？" /><published>2025-06-27T05:00:00+00:00</published><updated>2025-06-27T05:00:00+00:00</updated><id>https://jimmyblog.site/zh/2025/06/27/claude-code-vs-gemini-cli</id><content type="html" xml:base="https://jimmyblog.site/zh/2025/06/27/claude-code-vs-gemini-cli/"><![CDATA[<h2 id="google-cli-的發佈">Google CLI 的發佈</h2>

<p>Google 在 2025 年 6 月 26 日發佈了 Gemini CLI，也一起加入了Agent CLI 競賽的行列，並且提供開發者使用個人Google帳號登入就能免費使用Gemini CLI。
提供 Gemini 2.5 Pro 以及 100 token 的 context window。並且在model的請求額度可達到每分鐘 60 次，每日最多可達 1,000 次的模型執行額度，而這些 <strong>完全免費</strong></p>

<h2 id="claude-code-與-gemini-cli-的比較">Claude Code 與 Gemini CLI 的比較</h2>

<p>初步簡單的適用Gemini CLI，會覺得目前跟Claude Code使用上沒有太大的差別，
同樣支援免互動介面的操作模式，支援MCP的串接，比較特別的是原生支援了GoogleSearch跟WebFetch 的功能，
並且在記憶管理上可以說用 <code class="language-plaintext highlighter-rouge">--checkpoint</code> 來管理記憶體的使用以及支援 <code class="language-plaintext highlighter-rouge">-s</code> 進入sandbox 模式，避免污染本機環境</p>

<table>
  <thead>
    <tr>
      <th>功能</th>
      <th><strong>Claude Code</strong></th>
      <th><strong>Gemini CLI</strong></th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><strong>安裝</strong></td>
      <td><code class="language-plaintext highlighter-rouge">npm install -g @anthropic-ai/claude-code</code></td>
      <td><code class="language-plaintext highlighter-rouge">npm install -g @google/gemini-cli</code></td>
    </tr>
    <tr>
      <td><strong>MCP 支援</strong></td>
      <td>✅</td>
      <td>✅</td>
    </tr>
    <tr>
      <td><strong>遙測功能</strong></td>
      <td>✅</td>
      <td>✅</td>
    </tr>
    <tr>
      <td><strong>記憶體管理</strong></td>
      <td>使用 <code class="language-plaintext highlighter-rouge">CLAUDE.md</code> 進行記憶體管理</td>
      <td>支援 <code class="language-plaintext highlighter-rouge">--checkpointing</code> 來儲存和恢復對話與檔案狀態</td>
    </tr>
    <tr>
      <td><strong>安全性</strong></td>
      <td>權限可透過 <code class="language-plaintext highlighter-rouge">settings.json</code> 設定</td>
      <td>使用 <code class="language-plaintext highlighter-rouge">-s</code> 標記來沙盒化命令，避免不必要的系統變更</td>
    </tr>
    <tr>
      <td><strong>使用需求</strong></td>
      <td>需要 Claude Pro 訂閱</td>
      <td>免費使用，僅需 Google 帳戶；每分鐘 60 個模型請求，每日最多 1,000 個</td>
    </tr>
  </tbody>
</table>

<p><strong>安裝 Gemini CLI</strong>：</p>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>npm <span class="nb">install</span> <span class="nt">-g</span> @google/gemini-cli
</code></pre></div></div>

<p>當安裝成功後會看到以下訊息：</p>

<p><img src="https://static.jimmyblog.site/2025-06-27-claude-code-vs-gemini-cli/gemini_cli.webp" alt="安裝成功畫面" /></p>

<p>接下來就可以使用 Gemini CLI 了，以下是一些基本的使用指令：</p>

<p><strong>觀看 token 使用量</strong></p>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>/stats
</code></pre></div></div>

<p><strong>列出可用工具</strong></p>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>/tools
</code></pre></div></div>

<p><strong>不進入互動模式執行指令</strong></p>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>gemini <span class="nt">-p</span> <span class="s2">"你的prompt"</span>
</code></pre></div></div>

<h2 id="claude-code-會跌入神壇嗎">Claude Code 會跌入神壇嗎！？</h2>

<p>目前看來，Claude Code 仍然是個不錯的選擇，特別是已經整合了不同的平台。且Claude 4 在程式碼的理解以及解決問題的能力也非常出眾，但Gemini CLI 也提供了不想課金的使用者一個不錯的選擇，並且完全開源，也為產品帶來了更多的可能性。</p>]]></content><author><name></name></author><category term="Claude Code" /><category term="Gemini CLI" /><summary type="html"><![CDATA[Google CLI 的發佈]]></summary></entry></feed>