<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Hook Setup Guide——模具行业从业者必备知识手册]]></title><description><![CDATA[<p dir="auto">&lt;h2&gt;Hook Setup Guide&lt;/h2&gt;</p>
<p dir="auto">&lt;p&gt;Configure automatic self-improvement triggers for AI coding agents.&lt;/p&gt;</p>
<p dir="auto">&lt;h3&gt;Overview&lt;/h3&gt;</p>
<p dir="auto">&lt;p&gt;Hooks enable proactive learning capture by injecting reminders at key moments:&lt;/p&gt;<br />
&lt;ul&gt;<br />
&lt;li&gt;&lt;strong&gt;UserPromptSubmit&lt;/strong&gt;: Reminder after each prompt to evaluate learnings&lt;/li&gt;<br />
&lt;li&gt;&lt;strong&gt;PostToolUse (Bash)&lt;/strong&gt;: Error detection when commands fail&lt;/li&gt;<br />
&lt;/ul&gt;</p>
<p dir="auto">&lt;h3&gt;Claude Code Setup&lt;/h3&gt;</p>
<p dir="auto">&lt;h4&gt;Option 1: Project-Level Configuration&lt;/h4&gt;</p>
<p dir="auto">&lt;p&gt;Create &lt;code&gt;.claude/settings.json&lt;/code&gt; in your project root:&lt;/p&gt;</p>
<p dir="auto">&lt;pre&gt;&lt;code&gt;<br />
{<br />
"hooks": {<br />
"UserPromptSubmit": [<br />
{<br />
"matcher": "",<br />
"hooks": [<br />
{<br />
"type": "command",<br />
"command": "./skills/self-improvement/scripts/activator.sh"<br />
}<br />
]<br />
}<br />
],<br />
"PostToolUse": [<br />
{<br />
"matcher": "Bash",<br />
"hooks": [<br />
{<br />
"type": "command",<br />
"command": "./skills/self-improvement/scripts/error-detector.sh"<br />
}<br />
]<br />
}<br />
]<br />
}<br />
}<br />
&lt;/code&gt;&lt;/pre&gt;</p>
<p dir="auto">&lt;h4&gt;Option 2: User-Level Configuration&lt;/h4&gt;</p>
<p dir="auto">&lt;p&gt;Add to &lt;code&gt;~/.claude/settings.json&lt;/code&gt; for global activation:&lt;/p&gt;</p>
<p dir="auto">&lt;pre&gt;&lt;code&gt;<br />
{<br />
"hooks": {<br />
"UserPromptSubmit": [<br />
{<br />
"matcher": "",<br />
"hooks": [<br />
{<br />
"type": "command",<br />
"command": "~/.claude/skills/self-improvement/scripts/activator.sh"<br />
}<br />
]<br />
}<br />
]<br />
}<br />
}<br />
&lt;/code&gt;&lt;/pre&gt;</p>
<p dir="auto">&lt;h4&gt;Minimal Setup (Activator Only)&lt;/h4&gt;</p>
<p dir="auto">&lt;p&gt;For lower overhead, use only the UserPromptSubmit hook:&lt;/p&gt;</p>
<p dir="auto">&lt;pre&gt;&lt;code&gt;<br />
{<br />
"hooks": {<br />
"UserPromptSubmit": [<br />
{<br />
"matcher": "",<br />
"hooks": [<br />
{<br />
"type": "command",<br />
"command": "./skills/self-improvement/scripts/activator.sh"<br />
}<br />
]<br />
}<br />
]<br />
}<br />
}<br />
&lt;/code&gt;&lt;/pre&gt;</p>
<p dir="auto">&lt;h3&gt;Codex CLI Setup&lt;/h3&gt;</p>
<p dir="auto">&lt;p&gt;Codex uses the same hook system as Claude Code. Create &lt;code&gt;.codex/settings.json&lt;/code&gt;:&lt;/p&gt;</p>
<p dir="auto">&lt;pre&gt;&lt;code&gt;<br />
{<br />
"hooks": {<br />
"UserPromptSubmit": [<br />
{<br />
"matcher": "",<br />
"hooks": [<br />
{<br />
"type": "command",<br />
"command": "./skills/self-improvement/scripts/activator.sh"<br />
}<br />
]<br />
}<br />
]<br />
}<br />
}<br />
&lt;/code&gt;&lt;/pre&gt;</p>
<p dir="auto">&lt;h3&gt;GitHub Copilot Setup&lt;/h3&gt;</p>
<p dir="auto">&lt;p&gt;Copilot doesn't support hooks directly. Instead, add guidance to &lt;code&gt;.github/copilot-instructions.md&lt;/code&gt;:&lt;/p&gt;</p>
<p dir="auto">&lt;pre&gt;&lt;code&gt;</p>
<h2>Self-Improvement</h2>
<p dir="auto">After completing tasks that involved:</p>
<ul>
<li>Debugging non-obvious issues</li>
<li>Discovering workarounds</li>
<li>Learning project-specific patterns</li>
<li>Resolving unexpected errors</li>
</ul>
<p dir="auto">Consider logging the learning to <code>.learnings/</code> using the format from the self-improvement skill.</p>
<p dir="auto">For high-value learnings that would benefit other sessions, consider skill extraction.<br />
&lt;/code&gt;&lt;/pre&gt;</p>
<p dir="auto">&lt;h3&gt;Verification&lt;/h3&gt;</p>
<p dir="auto">&lt;h4&gt;Test Activator Hook&lt;/h4&gt;</p>
<p dir="auto">&lt;ol&gt;<br />
&lt;li&gt;Enable the hook configuration&lt;/li&gt;<br />
&lt;li&gt;Start a new Claude Code session&lt;/li&gt;<br />
&lt;li&gt;Send any prompt&lt;/li&gt;<br />
&lt;li&gt;Verify you see &lt;code&gt;&lt;self-improvement-reminder&gt;&lt;/code&gt; in the context&lt;/li&gt;<br />
&lt;/ol&gt;</p>
<p dir="auto">&lt;h4&gt;Test Error Detector Hook&lt;/h4&gt;</p>
<p dir="auto">&lt;ol&gt;<br />
&lt;li&gt;Enable PostToolUse hook for Bash&lt;/li&gt;<br />
&lt;li&gt;Run a command that fails: &lt;code&gt;ls /nonexistent/path&lt;/code&gt;&lt;/li&gt;<br />
&lt;li&gt;Verify you see &lt;code&gt;&lt;error-detected&gt;&lt;/code&gt; reminder&lt;/li&gt;<br />
&lt;/ol&gt;</p>
<p dir="auto">&lt;h4&gt;Dry Run Extract Script&lt;/h4&gt;</p>
<p dir="auto">&lt;pre&gt;&lt;code&gt;<br />
./skills/self-improvement/scripts/extract-skill.sh test-skill --dry-run<br />
&lt;/code&gt;&lt;/pre&gt;</p>
<p dir="auto">&lt;p&gt;Expected output shows the skill scaffold that would be created.&lt;/p&gt;</p>
<p dir="auto">&lt;h3&gt;Troubleshooting&lt;/h3&gt;</p>
<p dir="auto">&lt;h4&gt;Hook Not Triggering&lt;/h4&gt;</p>
<p dir="auto">&lt;ol&gt;<br />
&lt;li&gt;&lt;strong&gt;Check script permissions&lt;/strong&gt;: &lt;code&gt;chmod +x scripts/*.sh&lt;/code&gt;&lt;/li&gt;<br />
&lt;li&gt;&lt;strong&gt;Verify path&lt;/strong&gt;: Use absolute paths or paths relative to project root&lt;/li&gt;<br />
&lt;li&gt;&lt;strong&gt;Check settings location&lt;/strong&gt;: Project vs user-level settings&lt;/li&gt;<br />
&lt;li&gt;&lt;strong&gt;Restart session&lt;/strong&gt;: Hooks are loaded at session start&lt;/li&gt;<br />
&lt;/ol&gt;</p>
<p dir="auto">&lt;h4&gt;Permission Denied&lt;/h4&gt;</p>
<p dir="auto">&lt;pre&gt;&lt;code&gt;<br />
chmod +x ./skills/self-improvement/scripts/activator.sh<br />
chmod +x ./skills/self-improvement/scripts/error-detector.s</p>
<hr />
<p dir="auto">还有什么补充参数吗？一起完善。<br />
&lt;/code&gt;&lt;/pre&gt;</p>
]]></description><link>https://forum.mj7.cn/topic/7123/hook-setup-guide-模具行业从业者必备知识手册</link><generator>RSS for Node</generator><lastBuildDate>Fri, 02 Oct 2026 14:42:36 GMT</lastBuildDate><atom:link href="https://forum.mj7.cn/topic/7123.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 19 Apr 2026 21:35:26 GMT</pubDate><ttl>60</ttl></channel></rss>