{"id":225,"date":"2026-08-25T17:09:32","date_gmt":"2026-08-25T09:09:32","guid":{"rendered":"https:\/\/xiaotiao.store\/index.php\/2026\/08\/25\/claude-code-%e4%bd%bf%e7%94%a8%e6%95%99%e7%a8%8b\/"},"modified":"2026-08-25T17:09:33","modified_gmt":"2026-08-25T09:09:33","slug":"claude-code-%e4%bd%bf%e7%94%a8%e6%95%99%e7%a8%8b","status":"publish","type":"post","link":"https:\/\/xiaotiao.store\/index.php\/2026\/08\/25\/claude-code-%e4%bd%bf%e7%94%a8%e6%95%99%e7%a8%8b\/","title":{"rendered":"Claude Code \u4f7f\u7528\u6559\u7a0b"},"content":{"rendered":"<h1>Claude Code \u4f7f\u7528\u6559\u7a0b<\/h1>\n<h2>\u4ec0\u4e48\u662f Claude Code<\/h2>\n<p>Claude Code \u662f Anthropic \u63a8\u51fa\u7684\u57fa\u4e8e Claude \u6a21\u578b\u7684\u547d\u4ee4\u884c AI \u7f16\u7a0b\u52a9\u624b\u3002\u5b83\u53ef\u4ee5\u7406\u89e3\u81ea\u7136\u8bed\u8a00\u6307\u4ee4\uff0c\u81ea\u52a8\u751f\u6210\u3001\u4fee\u6539\u548c\u89e3\u91ca\u4ee3\u7801\uff0c\u652f\u6301\u591a\u79cd\u7f16\u7a0b\u8bed\u8a00\u548c\u9879\u76ee\u7ed3\u6784\u3002<\/p>\n<h2>\u5b89\u88c5 Claude Code<\/h2>\n<ol>\n<li><strong>\u524d\u63d0\u6761\u4ef6<\/strong><\/li>\n<li>\u5df2\u5b89\u88c5 Node.js\uff08\u5efa\u8bae &gt;=18\uff09<\/li>\n<li>\n<p>\u62e5\u6709 Anthropic API \u5bc6\u94a5\uff08\u9700\u5728 <a href=\"https:\/\/console.anthropic.com\/\">Anthropic Console<\/a> \u7533\u8bf7\uff09<\/p>\n<\/li>\n<li>\n<p><strong>\u901a\u8fc7 npm \u5b89\u88c5<\/strong><br \/>\n   <code>bash<br \/>\n   npm install -g @anthropic-ai\/claude-code<\/code><\/p>\n<\/li>\n<li>\n<p><strong>\u914d\u7f6e API \u5bc6\u94a5<\/strong><br \/>\n   <code>bash<br \/>\n   claude-code config set api_key &lt;\u4f60\u7684_API_\u5bc6\u94a5&gt;<\/code><br \/>\n   \u4e5f\u53ef\u4ee5\u901a\u8fc7\u73af\u5883\u53d8\u91cf <code>ANTHROPIC_API_KEY<\/code> \u8bbe\u7f6e\u3002<\/p>\n<\/li>\n<\/ol>\n<h2>\u57fa\u672c\u4f7f\u7528<\/h2>\n<h3>\u542f\u52a8\u4ea4\u4e92\u6a21\u5f0f<\/h3>\n<div class=\"codehilite\">\n<pre><span><\/span><code>claude-code\n<\/code><\/pre>\n<\/div>\n<p>\u8fdb\u5165\u540e\u4f1a\u770b\u5230\u63d0\u793a\u7b26 <code>&gt;<\/code>, \u53ef\u4ee5\u76f4\u63a5\u8f93\u5165\u81ea\u7136\u8bed\u8a00\u6307\u4ee4\u3002<\/p>\n<h3>\u5e38\u7528\u547d\u4ee4<\/h3>\n<table>\n<thead>\n<tr>\n<th>\u547d\u4ee4<\/th>\n<th>\u8bf4\u660e<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><code>\/help<\/code><\/td>\n<td>\u663e\u793a\u5e2e\u52a9\u4fe1\u606f<\/td>\n<\/tr>\n<tr>\n<td><code>\/exit<\/code><\/td>\n<td>\u9000\u51fa\u4ea4\u4e92\u6a21\u5f0f<\/td>\n<\/tr>\n<tr>\n<td><code>\/clear<\/code><\/td>\n<td>\u6e05\u5c4f<\/td>\n<\/tr>\n<tr>\n<td><code>\/model &lt;model-name&gt;<\/code><\/td>\n<td>\u5207\u6362\u4f7f\u7528\u7684 Claude \u6a21\u578b\uff08\u5982 <code>claude-3-opus-20240229<\/code>\uff09<\/td>\n<\/tr>\n<tr>\n<td><code>\/set &lt;key&gt; &lt;value&gt;<\/code><\/td>\n<td>\u8bbe\u7f6e\u914d\u7f6e\u9879\uff08\u5982 <code>api_key<\/code>, <code>max_tokens<\/code>\uff09<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>\u751f\u6210\u4ee3\u7801<\/h3>\n<p>\u76f4\u63a5\u63cf\u8ff0\u9700\u6c42\uff1a<\/p>\n<div class=\"codehilite\">\n<pre><span><\/span><code>&gt; \u521b\u5efa\u4e00\u4e2a Python Flask \u5e94\u7528\uff0c\u5b9e\u73b0 RESTful API\uff0c\u5305\u542b\u7528\u6237\u6ce8\u518c\u548c\u767b\u5f55\u63a5\u53e3\u3002\n<\/code><\/pre>\n<\/div>\n<p>Claude Code \u4f1a\u751f\u6210\u5bf9\u5e94\u7684\u9879\u76ee\u7ed3\u6784\u548c\u4ee3\u7801\u6587\u4ef6\u3002<\/p>\n<h3>\u4fee\u6539\u73b0\u6709\u4ee3\u7801<\/h3>\n<p>\u6253\u5f00\u6587\u4ef6\u540e\u8fdb\u884c\u7f16\u8f91\u6307\u4ee4\uff1a<\/p>\n<div class=\"codehilite\">\n<pre><span><\/span><code>&gt; \u5c06 app.py \u4e2d\u7684\u5bc6\u7801\u52a0\u5bc6\u65b9\u5f0f\u4ece md5 \u6539\u4e3a bcrypt\u3002\n<\/code><\/pre>\n<\/div>\n<p>Claude Code \u4f1a\u5b9a\u4f4d\u5230\u76f8\u5e94\u4f4d\u7f6e\u5e76\u7ed9\u51fa\u4fee\u6539\u5efa\u8bae\u6216\u76f4\u63a5\u5e94\u7528\u66f4\u6539\u3002<\/p>\n<h3>\u89e3\u91ca\u4ee3\u7801<\/h3>\n<p>\u9009\u4e2d\u4ee3\u7801\u5757\u540e\u4f7f\u7528\uff1a<\/p>\n<div class=\"codehilite\">\n<pre><span><\/span><code>&gt; \u89e3\u91ca\u8fd9\u6bb5\u4ee3\u7801\u7684\u4f5c\u7528\u3002\n<\/code><\/pre>\n<\/div>\n<p>\u6216\u8005\u76f4\u63a5\u5728\u7ec8\u7aef\u8f93\u5165\uff1a<\/p>\n<div class=\"codehilite\">\n<pre><span><\/span><code>&gt; explain \u6587\u4ef6\u8def\u5f84:\u884c\u53f7\n<\/code><\/pre>\n<\/div>\n<h3>\u5355\u5143\u6d4b\u8bd5\u751f\u6210<\/h3>\n<div class=\"codehilite\">\n<pre><span><\/span><code>&gt; \u4e3a src\/utils.py \u751f\u6210\u5355\u5143\u6d4b\u8bd5\u6587\u4ef6\u3002\n<\/code><\/pre>\n<\/div>\n<p>Claude Code \u4f1a\u57fa\u4e8e\u51fd\u6570\u7b7e\u53f7\u751f\u6210\u5bf9\u5e94\u7684\u6d4b\u8bd5\u7528\u4f8b\uff08\u4f7f\u7528 pytest \u6216 unittest \u7b49\u6846\u67b6\uff09\u3002<\/p>\n<h2>\u9ad8\u7ea7\u6280\u5de7<\/h2>\n<h3>\u4f7f\u7528\u5de5\u4f5c\u533a\uff08Workspace\uff09<\/h3>\n<p>\u5728\u9879\u76ee\u6839\u76ee\u5f55\u8fd0\u884c <code>claude-code<\/code> \u65f6\uff0c\u5b83\u4f1a\u81ea\u52a8\u52a0\u8f7d\u5f53\u524d\u76ee\u5f55\u4f5c\u4e3a\u5de5\u4f5c\u533a\uff0c\u4fbf\u4e8e\u8de8\u6587\u4ef6\u64cd\u4f5c\u3002<\/p>\n<h3>\u6307\u4ee4\u94fe\uff08Chaining\uff09<\/h3>\n<p>\u53ef\u4ee5\u5c06\u591a\u4e2a\u6307\u4ee4\u7528\u5206\u53f7\u5206\u9694\uff1a<\/p>\n<div class=\"codehilite\">\n<pre><span><\/span><code>&gt; \u521b\u5efa\u4e00\u4e2a React \u7ec4\u4ef6\uff1b\u4e3a\u5176\u6dfb\u52a0 props \u7c7b\u578b\u68c0\u67e5\uff1b\u751f\u6210\u5bf9\u5e94\u7684\u6545\u4e8b\u4e66\uff08Storybook\uff09\u6587\u4ef6\u3002\n<\/code><\/pre>\n<\/div>\n<h3>\u81ea\u5b9a\u4e49 Prompt \u6a21\u677f<\/h3>\n<p>\u5728 <code>~\/.claude-code\/prompts\/<\/code> \u76ee\u5f55\u4e0b\u6dfb\u52a0\u81ea\u5b9a\u4e49 <code>.md<\/code> \u6587\u4ef6\uff0c\u53ef\u5728\u6307\u4ee4\u4e2d\u4f7f\u7528 <code>\/prompt &lt;name&gt;<\/code> \u5f15\u7528\u3002<\/p>\n<h3>\u4e0e\u7248\u672c\u63a7\u5236\u7ed3\u5408<\/h3>\n<ul>\n<li>\u5728\u751f\u6210\u4ee3\u7801\u540e\uff0c\u53ef\u76f4\u63a5\u4f7f\u7528 <code>\/git add .<\/code>\u3001<code>\/git commit -m \"AI \u751f\u6210\u521d\u59cb\u4ee3\u7801\"<\/code> \u7b49 Git \u547d\u4ee4\uff08\u9700\u786e\u4fdd\u5df2\u5b89\u88c5 Git \u5e76\u5728\u9879\u76ee\u4e2d\u521d\u59cb\u5316\uff09\u3002<\/li>\n<li>\u4e5f\u53ef\u8ba9 Claude Code \u81ea\u884c\u5199\u63d0\u4ea4\u4fe1\u606f\uff1a<br \/>\n  &#8220;`<\/p>\n<blockquote>\n<p>\u751f\u6210\u63d0\u4ea4\u4fe1\u606f\uff1a\u63cf\u8ff0\u672c\u6b21\u66f4\u6539\u7684\u4e3b\u8981\u529f\u80fd\u3002<br \/>\n  &#8220;`<\/p>\n<\/blockquote>\n<\/li>\n<\/ul>\n<h2>\u5e38\u89c1\u95ee\u9898\u53ca\u89e3\u51b3\u529e\u6cd5<\/h2>\n<table>\n<thead>\n<tr>\n<th>\u95ee\u9898<\/th>\n<th>\u89e3\u51b3\u65b9\u6848<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>API \u9519\u8bef <code>401 Unauthorized<\/code><\/td>\n<td>\u68c0\u67e5 <code>api_key<\/code> \u662f\u5426\u6b63\u786e\u8bbe\u7f6e\uff0c\u786e\u4fdd\u73af\u5883\u53d8\u91cf\u6216\u914d\u7f6e\u6587\u4ef6\u4e2d\u672a\u6709\u7a7a\u683c\u3002<\/td>\n<\/tr>\n<tr>\n<td>\u751f\u6210\u4ee3\u7801\u7f3a\u5931\u4f9d\u8d56<\/td>\n<td>\u540e\u7eed\u624b\u52a8\u8fd0\u884c <code>npm install<\/code> \u6216 <code>pip install -r requirements.txt<\/code> \u5b89\u88c5\u6240\u9700\u5305\u3002<\/td>\n<\/tr>\n<tr>\n<td>\u60f3\u8981\u66f4\u957f\u7684\u8f93\u51fa\u4f46\u88ab\u622a\u65ad<\/td>\n<td>\u8c03\u6574 <code>max_tokens<\/code> \u914d\u7f6e\uff1a<code>\/set max_tokens 4096<\/code>\uff08\u89c6\u6a21\u578b\u800c\u5b9a\uff09\u3002<\/td>\n<\/tr>\n<tr>\n<td>\u4e2d\u6587\u8f93\u51fa\u4e71\u7801<\/td>\n<td>\u786e\u4fdd\u7ec8\u7aef\u4f7f\u7528 UTF-8 \u7f16\u7801\uff08\u5728 Linux\/macOS \u4e0a\u4e00\u822c\u9ed8\u8ba4\u5982\u6b64\uff09\uff0cWindows \u53ef\u4f7f\u7528 <code>chcp 65001<\/code>\u3002<\/td>\n<\/tr>\n<tr>\n<td>\u60f3\u8ba9 Claude Code \u53ea\u8bfb\u53d6\u7279\u5b9a\u6587\u4ef6<\/td>\n<td>\u4f7f\u7528 <code>\/ignore &lt;glob-pattern&gt;<\/code> \u5ffd\u7565\u4e0d\u9700\u8981\u7684\u6587\u4ef6\uff0c\u6216\u5728\u5de5\u4f5c\u533a\u5916\u6307\u5b9a\u7edd\u5bf9\u8def\u5f84\u3002<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2>\u6700\u4f73\u5b9e\u8df5<\/h2>\n<ol>\n<li><strong>\u5148\u63cf\u8ff0\u76ee\u6807\uff0c\u518d\u7ec6\u5316<\/strong>\uff1a\u5148\u7ed9\u51fa\u9ad8\u5c42\u6b21\u9700\u6c42\uff0c\u518d\u6839\u636e\u8fd4\u56de\u7ed3\u679c\u9010\u6b65\u7ec6\u8282\u3002<\/li>\n<li><strong>\u589e\u91cf\u4fee\u6539<\/strong>\uff1a\u4e0d\u8981\u4e00\u6b21\u6027\u8981\u6c42\u5927\u89c4\u6a21\u91cd\u6784\uff0c\u5148\u5c0f\u6539\uff0c\u68c0\u67e5\u540e\u518d\u7ee7\u7eed\u3002<\/li>\n<li><strong>\u5229\u7528\u89e3\u91ca\u529f\u80fd<\/strong>\uff1a\u751f\u6210\u4ee3\u7801\u540e\u7acb\u5373\u8ba9 Claude \u89e3\u91ca\uff0c\u786e\u4fdd\u7406\u89e3\u6b63\u786e\u3002<\/li>\n<li><strong>\u4fdd\u5b58\u4f1a\u8bdd<\/strong>\uff1a\u4ea4\u4e92\u8fc7\u7a0b\u53ef\u901a\u8fc7 <code>\/save-session &lt;filename&gt;<\/code> \u5bfc\u51fa\u4e3a markdown\uff0c\u4fbf\u4e8e\u540e\u590d\u73b0\u6216\u5206\u4eab\u3002<\/li>\n<li><strong>\u7ed3\u5408\u4ee3\u7801\u5ba1\u67e5<\/strong>\uff1a\u751f\u6210\u540e\u4f7f\u7528\u5de5\u5177\uff08\u5982 ESLint, pylint\uff09\u8fdb\u884c\u9759\u6001\u68c0\u67e5\uff0c\u5fc5\u8981\u65f6\u8ba9 Claude \u5e2e\u5fd9\u4fee\u590d\u3002<\/li>\n<\/ol>\n<h2>\u8d44\u6e90\u94fe\u63a5<\/h2>\n<ul>\n<li>\u5b98\u65b9\u6587\u6863\uff1ahttps:\/\/docs.anthropic.com\/claude-code<\/li>\n<li>GitHub \u793a\u4f8b\u9879\u76ee\uff1ahttps:\/\/github.com\/anthropics\/claude-code-examples<\/li>\n<li>Discord \u793e\u533a\uff1ahttps:\/\/discord.gg\/anthropic<\/li>\n<li>API \u5bc6\u94a5\u83b7\u53d6\uff1ahttps:\/\/console.anthropic.com\/<\/li>\n<\/ul>\n<p>\u795d\u4f7f\u7528\u6109\u5feb\uff01\u5982\u679c\u8fd8\u6709\u5176\u4ed6\u5177\u4f53\u9700\u6c42\uff0c\u968f\u65f6\u544a\u8bc9\u6211\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Claude Code \u4f7f\u7528\u6559\u7a0b \u4ec0\u4e48\u662f Claude Code Claude Code \u662f Anthropi&#8230;<\/p>\n","protected":false},"author":1,"featured_media":224,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-225","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/xiaotiao.store\/index.php\/wp-json\/wp\/v2\/posts\/225","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/xiaotiao.store\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/xiaotiao.store\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/xiaotiao.store\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/xiaotiao.store\/index.php\/wp-json\/wp\/v2\/comments?post=225"}],"version-history":[{"count":1,"href":"https:\/\/xiaotiao.store\/index.php\/wp-json\/wp\/v2\/posts\/225\/revisions"}],"predecessor-version":[{"id":226,"href":"https:\/\/xiaotiao.store\/index.php\/wp-json\/wp\/v2\/posts\/225\/revisions\/226"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/xiaotiao.store\/index.php\/wp-json\/wp\/v2\/media\/224"}],"wp:attachment":[{"href":"https:\/\/xiaotiao.store\/index.php\/wp-json\/wp\/v2\/media?parent=225"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/xiaotiao.store\/index.php\/wp-json\/wp\/v2\/categories?post=225"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/xiaotiao.store\/index.php\/wp-json\/wp\/v2\/tags?post=225"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}