6 6
7> 复制粘贴提示词到 Claude Code,按任务和角色标记。7> 复制粘贴提示词到 Claude Code,按任务和角色标记。
8 8
9export const PromptLibrary = ({text = {}, labels = {}, tagLabels = {}, phaseLabels = {}, sourceLabels = {}, catLabels = {}}) => {
10 const RAW = useMemo(() => [{
11 id: 'get-oriented-in-a',
12 sdlc: 'discover',
13 cat: 'Onboard',
14 startN: 1,
15 roles: [],
16 prompt: 'give me an overview of this codebase: architecture, key directories, and how the pieces connect',
17 nextHref: '/en/memory',
18 src: 'workflows'
19 }, {
20 id: 'explain-unfamiliar-code',
21 sdlc: 'discover',
22 cat: 'Understand',
23 roles: [],
24 prompt: 'explain what {path} does and how data flows through it. write it up as {format}',
25 slots: {
26 path: 'src/scheduler/queue.ts',
27 format: 'an HTML page with a diagram, then open it in my browser'
28 },
29 nextHref: '/en/output-styles',
30 src: 'workflows'
31 }, {
32 id: 'find-where-something-happens',
33 sdlc: 'discover',
34 cat: 'Understand',
35 startN: 2,
36 roles: [],
37 prompt: 'where do we {behavior}?',
38 slots: {
39 behavior: 'validate uploaded file types'
40 },
41 src: 'workflows'
42 }, {
43 id: 'see-what-depends-on',
44 sdlc: 'discover',
45 cat: 'Understand',
46 roles: [],
47 prompt: 'what would break if I deleted {target}?',
48 slots: {
49 target: 'the retryWithBackoff helper'
50 },
51 src: 'workflows'
52 }, {
53 id: 'trace-how-code-evolved',
54 sdlc: 'discover',
55 cat: 'Understand',
56 roles: [],
57 prompt: 'look through the commit history of {path} and summarize how it evolved and why',
58 slots: {
59 path: 'internal/auth/session.go'
60 },
61 src: 'best-practices'
62 }, {
63 id: 'scope-a-change-before',
64 sdlc: 'discover',
65 cat: 'Understand',
66 roles: ['pm', 'design'],
67 prompt: 'which files would I need to touch to {change}?',
68 slots: {
69 change: 'add a dark mode toggle to settings'
70 },
71 src: 'teams'
72 }, {
73 id: 'ask-the-codebase-a',
74 sdlc: 'discover',
75 cat: 'Understand',
76 roles: ['pm'],
77 prompt: 'I am a {role}. walk me through what happens when a user {action}, from the UI down to the result',
78 slots: {
79 role: 'PM',
80 action: 'clicks Export to PDF'
81 },
82 nextHref: '/en/output-styles',
83 src: 'teams'
84 }, {
85 id: 'plan-a-multi-file',
86 sdlc: 'design',
87 cat: 'Plan',
88 roles: ['pm', 'design'],
89 prompt: 'plan how to refactor the {target} to {goal}. list the files you would change, but don\'t edit anything yet',
90 slots: {
91 target: 'payment module',
92 goal: 'support multiple currencies'
93 },
94 src: 'workflows'
95 }, {
96 id: 'draft-a-spec-by',
97 sdlc: 'design',
98 cat: 'Plan',
99 roles: ['pm'],
100 prompt: 'I want to build {feature}. interview me about implementation, UX, edge cases, and tradeoffs until we have covered everything, then write the spec to SPEC.md',
101 slots: {
102 feature: 'per-workspace rate limits'
103 },
104 nextHref: '/en/skills',
105 src: 'best-practices'
106 }, {
107 id: 'turn-a-meeting-into',
108 sdlc: 'design',
109 cat: 'Plan',
110 roles: ['pm'],
111 prompt: 'read {input} and write up the action items, then create a ticket in {tracker} for each one, with acceptance criteria',
112 slots: {
113 input: '@meeting-notes.md',
114 tracker: 'our issue tracker'
115 },
116 needs: 'tracker',
117 nextHref: '/en/skills',
118 src: 'teams'
119 }, {
120 id: 'map-edge-cases-before',
121 sdlc: 'design',
122 cat: 'Plan',
123 roles: ['design', 'pm'],
124 prompt: 'list the error states, empty states, and edge cases for {feature} that the design needs to cover',
125 slots: {
126 feature: 'the file upload flow'
127 },
128 src: 'teams'
129 }, {
130 id: 'turn-a-mockup-into',
131 sdlc: 'design',
132 cat: 'Prototype',
133 roles: ['design', 'pm', 'marketing'],
134 paste: 'mockup',
135 prompt: 'here is a mockup. build a working prototype I can click through, matching the layout and states shown',
136 src: 'teams'
137 }, {
138 id: 'implement-from-a-screenshot',
139 sdlc: 'design',
140 cat: 'Prototype',
141 roles: ['design'],
142 paste: 'design',
143 needs: 'browser',
144 prompt: 'implement this design, then take a screenshot of the result, compare it to the original, and fix any differences',
145 nextHref: '/en/goal',
146 src: 'best-practices'
147 }, {
148 id: 'follow-an-existing-pattern',
149 sdlc: 'build',
150 cat: 'Implement',
151 roles: [],
152 prompt: 'look at how {example} is implemented to understand the pattern, then build {new} the same way',
153 slots: {
154 example: 'the existing webhook handler',
155 new: 'a payments webhook handler'
156 },
157 nextHref: '/en/memory',
158 src: 'best-practices'
159 }, {
160 id: 'generate-docs-for-code',
161 sdlc: 'build',
162 cat: 'Implement',
163 roles: ['docs'],
164 prompt: 'find {scope} without {format} comments and add them, matching the style already used in the file',
165 slots: {
166 scope: 'the public functions in src/auth/',
167 format: 'JSDoc'
168 },
169 src: 'workflows'
170 }, {
171 id: 'add-a-small-well',
172 sdlc: 'build',
173 cat: 'Implement',
174 roles: [],
175 prompt: 'add a {endpoint} endpoint that returns {payload}',
176 slots: {
177 endpoint: '/health',
178 payload: 'the app version and uptime'
179 },
180 src: 'workflows'
181 }, {
182 id: 'build-a-small-internal',
183 sdlc: 'build',
184 cat: 'Implement',
185 roles: ['pm', 'design', 'marketing', 'docs'],
186 prompt: 'create a {tool} using HTML, CSS, and vanilla JavaScript, then open it in my browser',
187 slots: {
188 tool: 'drag-and-drop Kanban board with three columns'
189 },
190 src: 'teams'
191 }, {
192 id: 'work-an-issue-end',
193 sdlc: 'build',
194 cat: 'Implement',
195 roles: [],
196 prompt: 'read issue #{issue}, implement the fix, and run the tests',
197 slots: {
198 issue: '312'
199 },
200 needs: 'gh',
201 src: 'workflows'
202 }, {
203 id: 'find-and-update-copy',
204 sdlc: 'build',
205 cat: 'Implement',
206 roles: ['design', 'docs', 'marketing'],
207 prompt: 'find every place we say "{copy}" or a close variant, show me each one in context, then update them all to "{new}". leave tests and the changelog alone',
208 slots: {
209 copy: 'Sign up free',
210 new: 'Start free trial'
211 },
212 src: 'teams'
213 }, {
214 id: 'draft-from-past-examples',
215 sdlc: 'build',
216 cat: 'Implement',
217 roles: ['docs', 'marketing', 'pm'],
218 prompt: 'read the {examples} in {folder} to learn the structure and voice, then draft a new one for {topic}',
219 slots: {
220 examples: 'privacy impact assessments',
221 folder: 'legal/pia/',
222 topic: 'the new analytics integration'
223 },
224 nextHref: '/en/skills',
225 src: 'legal'
226 }, {
227 id: 'write-tests-run-them',
228 sdlc: 'build',
229 cat: 'Test',
230 startN: 4,
231 roles: [],
232 prompt: 'write tests for {path}, run them, and fix any failures',
233 slots: {
234 path: 'app/parsers/feed.py'
235 },
236 nextHref: '/en/memory',
237 src: 'workflows'
238 }, {
239 id: 'drive-implementation-from-tests',
240 sdlc: 'build',
241 cat: 'Test',
242 roles: [],
243 prompt: 'write tests for {feature} first, then implement it until they pass',
244 slots: {
245 feature: 'the password reset flow'
246 },
247 src: 'ebook'
248 }, {
249 id: 'fill-gaps-from-a',
250 sdlc: 'build',
251 cat: 'Test',
252 roles: [],
253 prompt: 'read {report} and add tests for the lowest-covered files until each is above {target}%',
254 slots: {
255 report: 'coverage/coverage-summary.json',
256 target: '80'
257 },
258 nextHref: '/en/goal',
259 src: 'workflows'
260 }, {
261 id: 'migrate-a-pattern-across',
262 sdlc: 'build',
263 cat: 'Refactor',
264 roles: [],
265 prompt: 'migrate everything from {from} to {to}: identify every place that needs to change, then make the changes',
266 slots: {
267 from: 'the old logging API',
268 to: 'the structured logger'
269 },
270 src: 'workflows'
271 }, {
272 id: 'port-code-between-languages',
273 sdlc: 'build',
274 cat: 'Refactor',
275 roles: [],
276 prompt: 'port {source} to {target}, keeping the same {keep}',
277 slots: {
278 source: 'this Python module',
279 target: 'Rust',
280 keep: 'public API and test behavior'
281 },
282 src: 'teams'
283 }, {
284 id: 'optimize-against-a-measurable',
285 sdlc: 'build',
286 cat: 'Refactor',
287 roles: ['data'],
288 prompt: 'optimize {target} to bring {metric} from {current} down to under {goal}',
289 slots: {
290 target: 'the search query',
291 metric: 'p95 latency',
292 current: '2s',
293 goal: '500ms'
294 },
295 nextHref: '/en/goal',
296 src: 'ebook'
297 }, {
298 id: 'fix-a-precise-visual',
299 sdlc: 'build',
300 cat: 'Refactor',
301 roles: ['design'],
302 prompt: 'the {element} extends {amount} beyond the {container} on {viewport}. fix it.',
303 slots: {
304 element: 'login button',
305 amount: '20px',
306 container: 'card border',
307 viewport: 'mobile'
308 },
309 nextHref: '/en/desktop#preview-your-app',
310 src: 'ebook'
311 }, {
312 id: 'review-your-changes-before',
313 sdlc: 'build',
314 cat: 'Review',
315 startN: 5,
316 roles: [],
317 prompt: 'review my uncommitted changes and flag anything that looks risky before I commit',
318 nextHref: '/en/commands',
319 src: 'workflows'
320 }, {
321 id: 'review-a-pull-request',
322 sdlc: 'build',
323 cat: 'Review',
324 roles: [],
325 prompt: 'review PR #{pr} and summarize what changed, then list any concerns',
326 slots: {
327 pr: '247'
328 },
329 needs: 'gh',
330 nextHref: '/en/code-review',
331 src: 'workflows'
332 }, {
333 id: 'review-infrastructure-changes-before',
334 sdlc: 'build',
335 cat: 'Review',
336 roles: ['security', 'ops'],
337 paste: 'plan',
338 prompt: 'here is my Terraform plan output. what is this going to do, and is anything here going to cause problems?',
339 src: 'teams'
340 }, {
341 id: 'run-a-security-review',
342 sdlc: 'build',
343 cat: 'Review',
344 roles: ['security'],
345 prompt: 'use a subagent to review {path} for security issues and report what it finds',
346 slots: {
347 path: 'src/api/'
348 },
349 nextHref: '/en/sub-agents',
350 src: 'best-practices'
351 }, {
352 id: 'review-content-before-sending',
353 sdlc: 'build',
354 cat: 'Review',
355 roles: ['marketing', 'docs'],
356 prompt: 'review {file} for {concerns} and list anything I should fix before it goes to {reviewer}',
357 slots: {
358 file: 'launch-post.md',
359 concerns: 'unsupported claims, missing attributions, and brand-guideline issues',
360 reviewer: 'legal'
361 },
362 nextHref: '/en/skills',
363 src: 'legal'
364 }, {
365 id: 'course-correct-a-wrong',
366 sdlc: 'build',
367 cat: 'Steer',
368 roles: [],
369 prompt: 'that is not right: {feedback}. try a different approach',
370 slots: {
371 feedback: 'the function signature needs to stay backward-compatible'
372 },
373 nextHref: '/en/checkpointing',
374 src: 'best-practices'
375 }, {
376 id: 'narrow-the-scope-of',
377 sdlc: 'build',
378 cat: 'Steer',
379 roles: [],
380 prompt: 'that is too much. keep only the changes to {scope} and undo your other edits',
381 slots: {
382 scope: 'the validation logic in src/forms/'
383 },
384 src: 'best-practices'
385 }, {
386 id: 'turn-a-correction-into',
387 sdlc: 'build',
388 cat: 'Steer',
389 roles: [],
390 prompt: 'you keep {mistake}. add a rule to CLAUDE.md so this stops happening',
391 slots: {
392 mistake: 'using default exports when this project uses named exports'
393 },
394 nextHref: '/en/memory',
395 src: 'best-practices'
396 }, {
397 id: 'resolve-merge-conflicts',
398 sdlc: 'ship',
399 cat: 'Git',
400 roles: [],
401 prompt: 'resolve the merge conflicts in this branch and explain what you kept from each side',
402 src: 'workflows'
403 }, {
404 id: 'commit-with-a-generated',
405 sdlc: 'ship',
406 cat: 'Git',
407 roles: [],
408 prompt: 'commit these changes with a message that summarizes what I did',
409 src: 'workflows'
410 }, {
411 id: 'open-a-pull-request',
412 sdlc: 'ship',
413 cat: 'Git',
414 roles: [],
415 prompt: 'find the ticket about {topic} in {tracker} and open a PR that implements it',
416 slots: {
417 tracker: 'our issue tracker',
418 topic: 'the login timeout'
419 },
420 needs: 'tracker',
421 src: 'workflows'
422 }, {
423 id: 'draft-release-notes-from',
424 sdlc: 'ship',
425 cat: 'Release',
426 roles: ['pm', 'docs', 'marketing'],
427 prompt: 'compare {from} to {to} and draft release notes grouped by feature, fix, and breaking change',
428 slots: {
429 from: 'v2.3.0',
430 to: 'v2.4.0'
431 },
432 nextHref: '/en/skills',
433 src: 'workflows'
434 }, {
435 id: 'write-a-ci-workflow',
436 sdlc: 'ship',
437 cat: 'Release',
438 roles: ['ops'],
439 prompt: 'write a GitHub Actions workflow that {steps} on every push to {branch}',
440 slots: {
441 steps: 'runs the tests and deploys to staging',
442 branch: 'main'
443 },
444 src: 'workflows'
445 }, {
446 id: 'find-and-fix-a',
447 sdlc: 'operate',
448 cat: 'Debug',
449 startN: 3,
450 roles: [],
451 prompt: 'the {test} test is failing, find out why and fix it',
452 slots: {
453 test: 'UserAuth'
454 },
455 src: 'workflows'
456 }, {
457 id: 'investigate-a-reported-error',
458 sdlc: 'operate',
459 cat: 'Debug',
460 roles: ['ops'],
461 prompt: 'users are seeing {symptom} on {where}. investigate and tell me what is going on',
462 slots: {
463 symptom: '500 errors',
464 where: '/api/settings'
465 },
466 nextHref: '/en/web-quickstart#pre-fill-sessions',
467 src: 'workflows'
468 }, {
469 id: 'fix-a-build-error',
470 sdlc: 'operate',
471 cat: 'Debug',
472 roles: ['ops'],
473 paste: 'error',
474 prompt: 'here is a build error. fix the root cause and verify the build succeeds',
475 src: 'best-practices'
476 }, {
477 id: 'investigate-a-production-incident',
478 sdlc: 'operate',
479 cat: 'Incident',
480 roles: ['ops', 'security'],
481 prompt: '{symptom}. check the logs, recent deploys, and config changes, then tell me the most likely cause',
482 slots: {
483 symptom: 'the checkout endpoint started returning 500s an hour ago'
484 },
485 nextHref: '/en/mcp',
486 src: 'workflows'
487 }, {
488 id: 'diagnose-from-a-console',
489 sdlc: 'operate',
490 cat: 'Incident',
491 roles: ['ops', 'data'],
492 paste: 'screenshot',
493 prompt: 'here is a screenshot of {console}. walk me through why {resource} is failing and give me the exact commands to fix it',
494 slots: {
495 console: 'our Kubernetes dashboard',
496 resource: 'this pod'
497 },
498 src: 'teams'
499 }, {
500 id: 'query-logs-in-plain',
501 sdlc: 'operate',
502 cat: 'Incident',
503 roles: ['security', 'ops', 'data'],
504 prompt: 'show me all {events} for {scope} over {timeframe}. write the query, run it, and tell me what stands out',
505 slots: {
506 events: 'failed logins',
507 scope: 'the auth service',
508 timeframe: 'the past 24 hours'
509 },
510 needs: 'db',
511 src: 'cybersecurity'
512 }, {
513 id: 'analyze-a-data-file',
514 sdlc: 'operate',
515 cat: 'Data',
516 roles: ['data', 'pm', 'marketing'],
517 paste: 'csv',
518 prompt: 'read {file}, summarize the key patterns, and write the results to {output}',
519 slots: {
520 file: '@reports/q1-signups.csv',
521 output: 'an HTML page with charts, then open it in my browser'
522 },
523 nextHref: '/en/mcp',
524 src: 'teams'
525 }, {
526 id: 'generate-variations-from-performance',
527 sdlc: 'operate',
528 cat: 'Data',
529 roles: ['marketing', 'data'],
530 paste: 'csv',
531 prompt: 'read {file}, find the underperforming {items}, and generate {n} new variations that stay under {limit} characters',
532 slots: {
533 file: '@ads-performance.csv',
534 items: 'headlines',
535 n: '20',
536 limit: '90'
537 },
538 nextHref: '/en/mcp',
539 src: 'teams'
540 }, {
541 id: 'turn-a-recurring-task',
542 sdlc: 'operate',
543 cat: 'Automate',
544 roles: [],
545 prompt: 'create a /{name} skill for this project that {steps}',
546 slots: {
547 name: 'ship',
548 steps: 'runs the linter and tests, then drafts a commit message'
549 },
550 src: 'workflows'
551 }, {
552 id: 'add-a-hook-for',
553 sdlc: 'operate',
554 cat: 'Automate',
555 roles: [],
556 prompt: 'write a hook that {action} after every {event}',
557 slots: {
558 action: 'runs prettier',
559 event: 'edit to a .ts or .tsx file'
560 },
561 src: 'best-practices'
562 }, {
563 id: 'connect-a-tool-with',
564 sdlc: 'operate',
565 cat: 'Automate',
566 roles: [],
567 prompt: 'connect {server} via MCP so you can read its {data} directly',
568 slots: {
569 server: 'our error tracker',
570 data: 'stack traces'
571 },
572 src: 'workflows'
573 }, {
574 id: 'capture-what-to-remember',
575 sdlc: 'operate',
576 cat: 'Automate',
577 roles: ['pm', 'docs'],
578 prompt: 'summarize what we did this session and suggest what to add to CLAUDE.md',
579 src: 'teams'
580 }], []);
581 const PROMPTS = useMemo(() => {
582 if (typeof window !== 'undefined') {
583 const rawIds = new Set(RAW.map(p => p.id));
584 RAW.forEach(p => {
585 if (!text[p.id]) console.warn('[prompt-library] no text[] entry for id:', p.id);
586 });
587 Object.keys(text).forEach(k => {
588 if (!rawIds.has(k)) console.warn('[prompt-library] orphaned text[] key:', k);
589 });
590 }
591 return RAW.map(p => ({
592 ...p,
593 title: p.id,
594 teaches: '',
595 ...text[p.id] || ({})
596 }));
597 }, [RAW, text]);
598 const L = labels;
599 const TL = k => tagLabels[k] || k;
600 const CAT_TAG = useMemo(() => ({
601 Onboard: 'understand',
602 Understand: 'understand',
603 Plan: 'plan',
604 Prototype: 'prototype',
605 Implement: 'build',
606 Test: 'test',
607 Refactor: 'refactor',
608 Review: 'review',
609 Steer: 'steer',
610 Git: 'git',
611 Release: 'release',
612 Debug: 'debug',
613 Incident: 'debug',
614 Data: 'data',
615 Automate: 'automate'
616 }), []);
617 const TAGS = useMemo(() => ['understand', 'plan', 'prototype', 'build', 'test', 'refactor', 'review', 'steer', 'debug', 'git', 'release', 'data', 'automate', 'pm', 'design', 'docs', 'marketing', 'security', 'ops'], []);
618 const tagsOf = p => [CAT_TAG[p.cat], ...p.roles || []];
619 const doc = useMemo(() => {
620 const p = typeof window !== 'undefined' ? window.location.pathname : '';
621 const base = p.startsWith('/docs/') ? '/docs' : '';
622 const m = p.slice(base.length).match(/^\/([a-z]{2}(?:-[A-Z]{2})?)\//);
623 const locale = m ? m[1] : 'en';
624 return href => {
625 if (!href) return undefined;
626 if (href[0] === '#' || href.startsWith('https://')) return href;
627 if (!(/^\/[A-Za-z0-9]/).test(href)) return undefined;
628 return base + (href.startsWith('/en/') ? '/' + locale + href.slice(3) : href);
629 };
630 }, []);
631 const SAFE_HREF = /^(\/(?![\/\\\s])|#|https?:\/\/)/;
632 const linkify = s => {
633 const out = [];
634 let last = 0;
635 const re = /\[([^\]]+)\]\(([^)]+)\)/g;
636 for (let m; m = re.exec(s); ) {
637 if (m.index > last) out.push(s.slice(last, m.index));
638 out.push(SAFE_HREF.test(m[2]) ? <a key={m.index} href={doc(m[2])}>{m[1]}</a> : m[1]);
639 last = re.lastIndex;
640 }
641 if (last < s.length) out.push(s.slice(last));
642 return out;
643 };
644 const codeify = s => s.split(/(`[^`]+`)/g).map((part, i) => part[0] === '`' ? <code key={i}>{part.slice(1, -1)}</code> : part);
645 const SOURCES = useMemo(() => ({
646 'workflows': '/en/common-workflows',
647 'teams': 'https://claude.com/blog/how-anthropic-teams-use-claude-code',
648 'legal': 'https://claude.com/blog/how-anthropic-uses-claude-legal',
649 'cybersecurity': 'https://claude.com/blog/how-anthropic-uses-claude-cybersecurity',
650 'best-practices': '/en/best-practices',
651 'ebook': 'https://resources.anthropic.com/hubfs/Scaling%20agentic%20coding%20across%20your%20organization.pdf'
652 }), []);
653 const [mounted, setMounted] = useState(false);
654 const [q, setQ] = useState('');
655 const [start, setStart] = useState(true);
656 const [sel, setSel] = useState(null);
657 const [openId, setOpenId] = useState(null);
658 const [copied, setCopied] = useState(null);
659 const [fills, setFills] = useState({});
660 const copyTimer = useRef(null);
661 useEffect(() => {
662 setMounted(true);
663 return () => clearTimeout(copyTimer.current);
664 }, []);
665 const setFill = (id, key, val) => setFills(f => ({
666 ...f,
667 [id + '.' + key]: val
668 }));
669 const fillOf = (p, key) => {
670 const v = fills[p.id + '.' + key];
671 return v !== undefined ? v : p.slots && p.slots[key] !== undefined ? p.slots[key] : '';
672 };
673 const assemble = p => p.prompt.replace(/\{(\w+)\}/g, (_, k) => fillOf(p, k) || p.slots && p.slots[k] || k);
674 const preview = p => p.prompt.replace(/\{(\w+)\}/g, (_, k) => p.slots && p.slots[k] || k);
675 const bodyText = p => preview(p) + ' ' + p.teaches.replace(/\[([^\]]+)\]\([^)]+\)/g, '$1') + ' ' + (p.next || '');
676 const WIDE_RE = /[\u1100-\u115F\u2E80-\uA4CF\uAC00-\uD7A3\uF900-\uFAFF\uFE30-\uFE4F\uFF00-\uFF60\uFFE0-\uFFE6]/g;
677 const widthFor = s => {
678 const t = typeof s === 'string' ? s : '';
679 return t.length + (t.match(WIDE_RE) || []).length + 3 + 'ch';
680 };
681 const ql = q.trim().toLowerCase();
682 const toggleTag = k => {
683 setStart(false);
684 setSel(s => !ql && s === k ? null : k);
685 };
686 const clear = () => {
687 setStart(false);
688 setSel(null);
689 setQ('');
690 };
691 const results = useMemo(() => {
692 const list = PROMPTS.filter(p => {
693 if (ql) return p.title.toLowerCase().includes(ql) || bodyText(p).toLowerCase().includes(ql);
694 if (start) return !!p.startN;
695 if (sel) return tagsOf(p).includes(sel);
696 return true;
697 });
698 if (ql) return list;
699 if (start) return list.sort((a, b) => a.startN - b.startN);
700 if (sel) return list.sort((a, b) => (a.roles || []).length - (b.roles || []).length || (b.sdlc === 'operate') - (a.sdlc === 'operate'));
701 return list;
702 }, [PROMPTS, ql, start, sel]);
703 const matchSnippet = p => {
704 if (!ql || p.title.toLowerCase().includes(ql)) return null;
705 const txt = bodyText(p);
706 const at = txt.toLowerCase().indexOf(ql);
707 if (at < 0) return null;
708 const lo = Math.max(0, at - 30), hi = Math.min(txt.length, at + ql.length + 50);
709 return [lo > 0 ? '…' : '', txt.slice(lo, at), <mark key="m">{txt.slice(at, at + ql.length)}</mark>, txt.slice(at + ql.length, hi), hi < txt.length ? '…' : ''];
710 };
711 const grouped = useMemo(() => {
712 if (start && !q.trim()) return [];
713 const g = {};
714 for (const p of results) {
715 const key = p.sdlc + '|' + p.cat;
716 (g[key] = g[key] || ({
717 sdlc: p.sdlc,
718 cat: p.cat,
719 items: []
720 })).items.push(p);
721 }
722 return Object.values(g);
723 }, [results, start, q]);
724 const copy = async (str, id) => {
725 try {
726 await navigator.clipboard.writeText(str);
727 } catch {
728 const ta = document.createElement('textarea');
729 ta.value = str;
730 ta.setAttribute('readonly', '');
731 ta.style.position = 'fixed';
732 ta.style.opacity = '0';
733 document.body.appendChild(ta);
734 ta.select();
735 document.execCommand('copy');
736 document.body.removeChild(ta);
737 }
738 clearTimeout(copyTimer.current);
739 setCopied(id);
740 copyTimer.current = setTimeout(() => setCopied(null), 1600);
741 };
742 const promptBody = p => {
743 if (!p.slots) return <code>{p.prompt}</code>;
744 const parts = p.prompt.split(/(\{\w+\})/g);
745 return <code>
746 {parts.map((part, idx) => {
747 const m = part.match(/^\{(\w+)\}$/);
748 if (!m) return <span key={idx}>{part}</span>;
749 const k = m[1];
750 const val = fillOf(p, k);
751 return <input key={idx} type="text" className="pl-slot" value={val} placeholder={p.slots[k] || k} aria-label={k} style={{
752 width: widthFor(val || p.slots[k])
753 }} onChange={e => setFill(p.id, k, e.target.value)} onFocus={e => e.target.select()} onClick={e => e.stopPropagation()} />;
754 })}
755 </code>;
756 };
757 const card = p => {
758 const open = openId === p.id;
759 const srcHref = SOURCES[p.src];
760 const srcLabel = sourceLabels[p.src];
761 const snip = matchSnippet(p);
762 return <div key={p.id} className={'pl-card' + (open ? ' pl-open' : '')}>
763 <button type="button" className="pl-head" onClick={() => setOpenId(open ? null : p.id)} aria-expanded={open}>
764 <span className="pl-title">{p.title}</span>
765 {!!p.startN && <span className="pl-chip">{L.startHere} · {p.startN}</span>}
766 </button>
767 {snip ? <div className="pl-match">{snip}</div> : <code className="pl-prompt-preview">{preview(p)}</code>}
768 {open && <div className="pl-body">
769 <div className="pl-label">{p.slots ? L.fillAndCopy : L.copyThis}</div>
770 {p.needs && L.needs && L.needs[p.needs] && <div className="pl-hint pl-needs">
771 <span className="pl-needs-label">{L.needsLabel}</span> {linkify(L.needs[p.needs])}
772 </div>}
773 {p.paste && L.paste && L.paste[p.paste] && <div className="pl-hint pl-paste">{L.paste[p.paste]}</div>}
774 {p.slots && <div className="pl-hint">
775 {L.hintBefore} <span className="pl-hint-chip">{L.hintChip}</span> {L.hintAfter}
776 </div>}
777 <div className="pl-prompt-box">
778 <span className="pl-caret">{'❯'}</span>
779 {promptBody(p)}
780 <button type="button" className="pl-copy" onClick={() => copy(assemble(p), p.id)}>
781 {copied === p.id ? L.copied : L.copy}
782 </button>
783 </div>
784 <div className="pl-label">{L.whyWorks}</div>
785 <div className="pl-teaches">{linkify(p.teaches)}</div>
786 {p.nextHref && p.next && SAFE_HREF.test(p.nextHref) && <div className="pl-next">
787 <span className="pl-next-label">{L.makeItStick}</span>
788 <a href={doc(p.nextHref)}>{codeify(p.next)} →</a>
789 </div>}
790 {srcLabel && <div className="pl-src">{L.from} {srcHref ? <a href={doc(srcHref)}>{srcLabel}</a> : srcLabel}</div>}
791 </div>}
792 </div>;
793 };
794 const STYLES = useMemo(() => `
795.pl {
796 --pl-accent: #D97757;
797 --pl-accent-bg: rgba(217,119,87,0.07);
798 --pl-bg: #fff;
799 --pl-surface: #FAFAF7;
800 --pl-border: #E8E6DC;
801 --pl-border-subtle: rgba(31,30,29,0.08);
802 --pl-text: #141413;
803 --pl-text-2: #5E5D59;
804 --pl-text-3: #73726C;
805 --pl-text-4: #9C9A92;
806 --pl-mono: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, monospace);
807 font-family: 'Anthropic Sans', -apple-system, BlinkMacSystemFont, sans-serif;
808 font-size: 16px; color: var(--pl-text); margin: 8px 0 32px;
809}
810.dark .pl {
811 --pl-bg: #1f1e1d;
812 --pl-surface: #262624;
813 --pl-border: #3d3d3a;
814 --pl-border-subtle: rgba(240,238,230,0.08);
815 --pl-text: #f0eee6;
816 --pl-text-2: #bfbdb4;
817 --pl-text-3: #91908a;
818 --pl-text-4: #73726c;
819}
820.pl *, .pl *::before, .pl *::after { box-sizing: border-box; }
821.pl button { font-family: inherit; cursor: pointer; }
822.pl a { color: var(--pl-accent); text-decoration: none; }
823.pl a:hover { text-decoration: underline; }
824
825.pl-search {
826 display: flex; align-items: center; gap: 10px;
827 padding: 14px 18px; background: var(--pl-surface);
828 border: 1px solid var(--pl-border); border-radius: 12px;
829 margin-bottom: 14px;
830}
831.pl-search input {
832 flex: 1; border: none; outline: none; background: transparent;
833 font-size: 16px; color: var(--pl-text);
834}
835.pl-search input::placeholder { color: var(--pl-text-4); }
836
837.pl-tags { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 18px; }
838.pl-tag {
839 padding: 7px 14px; border: 1px solid var(--pl-border); background: var(--pl-bg);
840 font-size: 14px; color: var(--pl-text-2); border-radius: 999px;
841}
842.pl-tag:hover { background: var(--pl-surface); }
843.pl-tag.pl-on { background: var(--pl-text); border-color: var(--pl-text); color: var(--pl-bg); }
844.pl-tag.pl-start { color: var(--pl-accent); font-weight: 500; }
845.pl-tag.pl-start.pl-on { background: var(--pl-accent); border-color: var(--pl-accent); color: #fff; }
846.pl-tags.pl-dim .pl-tag { opacity: 0.5; }
847.pl-tags.pl-dim .pl-tag:hover { opacity: 1; }
848.pl-sep { width: 1px; height: 22px; background: var(--pl-border); margin: 0 4px; }
849.pl-clear { border: none; background: none; font-size: 13px; color: var(--pl-text-4); padding: 4px 6px; }
850.pl-clear:hover { color: var(--pl-text-2); }
851.pl-count { margin-left: auto; font-size: 14px; color: var(--pl-text-4); }
852
853.pl-group-h {
854 font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase;
855 color: var(--pl-text-4); margin: 24px 0 12px;
856}
857.pl-group-h .pl-phase { color: var(--pl-text-3); }
858.pl-card {
859 border: 1px solid var(--pl-border-subtle); border-radius: 10px;
860 margin-bottom: 12px; background: var(--pl-bg); overflow: hidden;
861 padding: 14px 18px;
862}
863.pl-card.pl-open { border-color: var(--pl-border); background: var(--pl-surface); }
864.pl-head {
865 width: 100%; display: flex; align-items: baseline; gap: 12px;
866 border: none; background: transparent; text-align: left; padding: 0;
867}
868.pl-head:focus-visible { outline: 2px solid var(--pl-accent); outline-offset: 2px; border-radius: 6px; }
869.pl-title {
870 flex: 1; font-size: 17px; font-weight: 500; color: var(--pl-text);
871 white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
872}
873.pl-prompt-preview {
874 display: block; font-family: var(--pl-mono); font-size: 13.5px; color: var(--pl-text-3);
875 margin-top: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
876}
877.pl-chip {
878 font-size: 11px; letter-spacing: 0.05em; text-transform: uppercase;
879 padding: 3px 9px; border-radius: 999px; flex-shrink: 0;
880 background: var(--pl-accent-bg); color: var(--pl-accent);
881}
882
883.pl-body { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--pl-border-subtle); }
884.pl-label {
885 font-size: 11.5px; letter-spacing: 0.08em; text-transform: uppercase;
886 color: var(--pl-text-4); margin: 12px 0 8px;
887}
888.pl-prompt-box {
889 display: flex; align-items: center; gap: 10px;
890 padding: 14px 16px; background: #141413; color: #f0eee6;
891 border-radius: 8px; font-family: var(--pl-mono); font-size: 15px;
892}
893.pl-caret { color: var(--pl-accent); flex-shrink: 0; }
894.pl-prompt-box code { flex: 1; background: none; padding: 0; color: inherit; white-space: pre-wrap; line-height: 1.9; }
895.pl-slot {
896 font-family: var(--pl-mono); font-size: inherit;
897 background: rgba(217,119,87,0.15); color: #f0eee6;
898 border: none; border-bottom: 1.5px dashed var(--pl-accent);
899 border-radius: 4px 4px 0 0; padding: 2px 6px; margin: 0 1px;
900 outline: none; min-width: 6ch; max-width: 100%;
901 box-sizing: content-box; cursor: text;
902}
903.pl-slot:hover { background: rgba(217,119,87,0.22); }
904.pl-slot:focus { background: rgba(217,119,87,0.28); border-bottom-style: solid; }
905.pl-slot::placeholder { color: rgba(240,238,230,0.4); font-style: italic; }
906.pl-hint { font-size: 14px; color: var(--pl-text-3); margin: 0 0 10px; }
907.pl-paste { color: var(--pl-text-2); }
908.pl-needs { color: var(--pl-text-2); }
909.pl-needs-label {
910 display: inline-block; font-size: 10.5px; letter-spacing: 0.06em;
911 text-transform: uppercase; padding: 2px 7px; margin-right: 6px;
912 border-radius: 4px; background: var(--pl-accent-bg); color: var(--pl-accent);
913}
914.pl-hint-chip {
915 font-family: var(--pl-mono); font-size: 0.92em;
916 background: var(--pl-accent-bg); color: var(--pl-accent);
917 border-bottom: 1.5px dashed var(--pl-accent);
918 border-radius: 3px 3px 0 0; padding: 1px 5px;
919}
920.pl-copy {
921 font-size: 12.5px; padding: 6px 12px; border-radius: 6px;
922 background: var(--pl-accent); color: #fff; border: none; flex-shrink: 0;
923}
924.pl-teaches { display: block; font-size: 15.5px; color: var(--pl-text-2); margin: 4px 0 0; line-height: 1.6; }
925.pl-match {
926 display: block; font-size: 13.5px; color: var(--pl-text-3);
927 margin-top: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
928}
929.pl-match mark { background: var(--pl-accent-bg); color: var(--pl-text); padding: 1px 2px; border-radius: 3px; }
930.pl-next {
931 display: flex; align-items: baseline; gap: 10px;
932 margin: 14px 0 0; padding: 10px 12px;
933 background: var(--pl-accent-bg); border-radius: 8px; font-size: 14.5px;
934}
935.pl-next-label {
936 font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase;
937 color: var(--pl-accent); font-weight: 600; flex-shrink: 0;
938}
939.pl-src { display: block; font-size: 14px; color: var(--pl-text-4); margin: 14px 0 0; }
940
941.pl-show-all {
942 display: block; width: 100%; padding: 14px; margin-top: 4px;
943 border: 1px dashed var(--pl-border); border-radius: 10px;
944 background: transparent; font-size: 15px; color: var(--pl-accent);
945 text-align: center;
946}
947.pl-show-all:hover { background: var(--pl-accent-bg); border-style: solid; }
948
949.pl-empty {
950 padding: 32px; text-align: center; color: var(--pl-text-4);
951 border: 1px dashed var(--pl-border); border-radius: 10px;
952}
953`, []);
954 if (!mounted) return <div className="pl" style={{
955 minHeight: 480
956 }} />;
957 return <div className="pl">
958 <style>{STYLES}</style>
959
960 <div className="pl-search">
961 <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" style={{
962 color: 'var(--pl-text-4)'
963 }}>
964 <circle cx="11" cy="11" r="7" /><line x1="21" y1="21" x2="16.65" y2="16.65" />
965 </svg>
966 <input type="text" placeholder={L.search} value={q} onChange={e => {
967 setQ(e.target.value);
968 if (e.target.value) setStart(false);
969 }} aria-label={L.search} />
970 </div>
971
972 <div className={'pl-tags' + (ql ? ' pl-dim' : '')}>
973 <button type="button" className={'pl-tag pl-start' + (!ql && start ? ' pl-on' : '')} onClick={() => {
974 setQ('');
975 setStart(!start);
976 if (!start) setSel(null);
977 }}>
978 ★ {L.startHere}
979 </button>
980 <span className="pl-sep" />
981 {TAGS.map(k => <button key={k} type="button" aria-pressed={!ql && sel === k} className={'pl-tag' + (!ql && sel === k ? ' pl-on' : '')} onClick={() => {
982 setQ('');
983 toggleTag(k);
984 }}>
985 {TL(k)}
986 </button>)}
987 {(start || sel || q) && <button type="button" className="pl-clear" onClick={clear}>{L.clear}</button>}
988 <span className="pl-count">{results.length} {results.length === 1 ? L.prompt : L.prompts}</span>
989 </div>
990
991 {results.length === 0 ? <div className="pl-empty">
992 {L.noMatch} {ql ? <code>{q}</code> : null} <button type="button" className="pl-clear" onClick={clear}>{L.clear}</button>
993 </div> : !ql && start ? <div>
994 <div className="pl-group-h">{L.startHereHeader}</div>
995 {results.map(card)}
996 <button type="button" className="pl-show-all" onClick={clear}>
997 {L.showAll && L.showAll.replace('{n}', PROMPTS.length)} →
998 </button>
999 </div> : grouped.map(g => <div key={g.sdlc + '|' + g.cat}>
1000 <div className="pl-group-h"><span className="pl-phase">{phaseLabels[g.sdlc] || g.sdlc}</span> · {catLabels[g.cat] || g.cat}</div>
1001 {g.items.map(card)}
1002 </div>)}
1003 </div>;
1004};
1005
1006这是一个提示词库,可以复制到 Claude Code 中使用。使用它来探索你还没有尝试过的工作方式,或者当你不确定从哪里开始时。9这是一个提示词库,可以复制到 Claude Code 中使用。使用它来探索你还没有尝试过的工作方式,或者当你不确定从哪里开始时。
1007 10
1008这些提示词来自各种 Anthropic 指南,包括[常见工作流](/docs/zh-CN/common-workflows)、[最佳实践](/docs/zh-CN/best-practices)和[Anthropic 团队如何使用 Claude Code](https://claude.com/blog/how-anthropic-teams-use-claude-code)。它们是起点而不是脚本。打开任何提示词下的**为什么这样做有效**来查看其背后的模式,这样你可以编写自己的提示词。11这些提示词来自各种 Anthropic 指南,包括[常见工作流](/docs/zh-CN/common-workflows)、[最佳实践](/docs/zh-CN/best-practices)和[Anthropic 团队如何使用 Claude Code](https://claude.com/blog/how-anthropic-teams-use-claude-code)。它们是起点而不是脚本。打开任何提示词下的**为什么这样做有效**来查看其背后的模式,这样你可以编写自己的提示词。
1009 12
1010export const labels = {13## 这些提示词为什么有效
1011 startHere: "从这里开始",
1012 startHereHeader: "五个首先尝试的提示词",
1013 showAll: "显示全部 {n} 个提示词",
1014 search: "搜索提示词…",
1015 clear: "清除",
1016 prompt: "提示词",
1017 prompts: "提示词",
1018 noMatch: "没有匹配的提示词",
1019 fillAndCopy: "填写并复制",
1020 copyThis: "复制此提示词",
1021 hintBefore: "在",
1022 hintChip: "高亮显示的",
1023 hintAfter: "字段中输入以自定义,然后复制。",
1024 copy: "复制",
1025 copied: "已复制",
1026 whyWorks: "为什么这样做有效",
1027 makeItStick: "使其坚持",
1028 from: "来自",
1029 paste: {
1030 mockup: "粘贴、拖动或 @-提及你的模型图像,然后发送此内容:",
1031 design: "粘贴、拖动或 @-提及你的设计图像,然后发送此内容:",
1032 screenshot: "粘贴、拖动或 @-提及你的屏幕截图,然后发送此内容:",
1033 plan: "首先将你的计划输出粘贴到提示词中,然后发送此内容:",
1034 error: "首先将错误输出粘贴到提示词中,然后发送此内容:",
1035 csv: "将你的文件拖到提示词中,或将下面的路径替换为你自己的 @-提及:"
1036 },
1037 needsLabel: "需要",
1038 needs: {
1039 tracker: "你的问题跟踪器添加为 [claude.ai 连接器](/docs/zh-CN/mcp#use-mcp-servers-from-claude-ai) 或 [MCP 服务器](/docs/zh-CN/mcp)。",
1040 gh: "[gh CLI](https://cli.github.com) 已认证,或 GitHub 添加为 [claude.ai 连接器](/docs/zh-CN/mcp#use-mcp-servers-from-claude-ai)。",
1041 browser: "Claude 能够呈现和截图结果的方式。[桌面应用](/docs/zh-CN/desktop#preview-your-app)内置了此功能。在终端中,安装 [Chrome 扩展](/docs/zh-CN/chrome)或 Playwright [MCP](/docs/zh-CN/mcp) 服务器。",
1042 db: "你的数据仓库或日志存储添加为 [claude.ai 连接器](/docs/zh-CN/mcp#use-mcp-servers-from-claude-ai) 或 [MCP 服务器](/docs/zh-CN/mcp)。"
1043 }
1044};
1045
1046export const tagLabels = {
1047 understand: "理解",
1048 plan: "计划",
1049 prototype: "原型",
1050 build: "构建",
1051 test: "测试",
1052 refactor: "重构",
1053 review: "审查",
1054 steer: "引导",
1055 debug: "调试",
1056 git: "Git",
1057 release: "发布",
1058 data: "数据",
1059 automate: "自动化",
1060 pm: "产品",
1061 design: "设计",
1062 docs: "文档",
1063 marketing: "营销",
1064 security: "安全",
1065 ops: "值班"
1066};
1067
1068export const phaseLabels = {
1069 discover: "发现",
1070 design: "设计",
1071 build: "构建",
1072 ship: "发布",
1073 operate: "运营"
1074};
1075
1076export const sourceLabels = {
1077 workflows: "常见工作流",
1078 teams: "Anthropic 团队如何使用 Claude Code",
1079 legal: "Anthropic 如何在法律中使用 Claude",
1080 cybersecurity: "Anthropic 如何在网络安全中使用 Claude",
1081 "best-practices": "最佳实践",
1082 ebook: "扩展代理编码指南"
1083};
1084
1085export const catLabels = {
1086 Onboard: "入职",
1087 Understand: "理解",
1088 Plan: "计划",
1089 Prototype: "原型",
1090 Implement: "实现",
1091 Test: "测试",
1092 Refactor: "重构",
1093 Review: "审查",
1094 Steer: "引导",
1095 Git: "Git",
1096 Release: "发布",
1097 Debug: "调试",
1098 Incident: "事件",
1099 Data: "数据",
1100 Automate: "自动化"
1101};
1102
1103export const text = {
1104 "get-oriented-in-a": {
1105 title: "快速熟悉新仓库",
1106 teaches: "描述您想了解的内容,而不是要读哪些文件。Claude 会自行探索项目,并返回一份关于各部分如何组合在一起的摘要。",
1107 next: "运行 `/init` 来设置 `CLAUDE.md`,以便 Claude 在每个会话中记住这些内容",
1108 prompt: "给我概述一下这个代码库:架构、关键目录,以及各部分之间如何关联"
1109 },
1110 "explain-unfamiliar-code": {
1111 title: "解释不熟悉的代码",
1112 teaches: "指明文件,并说明您希望答案采用的格式。可以把 HTML 页面换成图表、要点列表,或任何适合您学习方式的形式。",
1113 next: "设置输出样式,以便 Claude 始终以您喜欢的格式进行解释",
1114 prompt: "解释 {path} 的作用以及数据如何在其中流动。将其写成{format}",
1115 slots: {
1116 path: "src/scheduler/queue.ts",
1117 format: "一个带图表的 HTML 页面,然后在我的浏览器中打开它"
1118 }
1119 },
1120 "find-where-something-happens": {
1121 title: "找到某个行为发生的位置",
1122 teaches: "按行为而不是按文件名搜索。即使您不知道文件叫什么或位于哪个目录,搜索也同样有效。",
1123 prompt: "我们在哪里{behavior}?",
1124 slots: {
1125 behavior: "验证上传的文件类型"
1126 }
1127 },
1128 "see-what-depends-on": {
1129 title: "删除前检查会破坏什么",
1130 teaches: "在删除任何内容之前先询问。调用方列表和下游影响会告诉您,这只是一行代码的清理,还是一项需要协调的更改。",
1131 prompt: "如果我删除{target},会破坏什么?",
1132 slots: {
1133 target: "retryWithBackoff 辅助函数"
1134 }
1135 },
1136 "trace-how-code-evolved": {
1137 title: "追踪代码如何演变",
1138 teaches: "当问题是“为什么”而不是“是什么”时,请指向提交历史。Claude 会读取您所用版本控制系统的日志和 blame 信息,并解释当前实现背后的决策。",
1139 prompt: "查看 {path} 的提交历史,总结它是如何演变的以及原因",
1140 slots: {
1141 path: "internal/auth/session.go"
1142 }
1143 },
1144 "scope-a-change-before": {
1145 title: "开始前确定更改的范围",
1146 teaches: "在将工作列入路线图之前先评估其规模。文件列表会告诉您,这只涉及一个组件,还是一项跨越多个部分的更改。",
1147 prompt: "要{change},我需要修改哪些文件?",
1148 slots: {
1149 change: "在设置中添加深色模式开关"
1150 }
1151 },
1152 "ask-the-codebase-a": {
1153 title: "向代码库提出产品问题",
1154 teaches: "说明您的角色,以便答案处于合适的深度。Claude 会根据源代码解释产品实际做了什么,您无需亲自阅读代码。",
1155 next: "设置输出样式,以便 Claude 始终以这一深度给出回答",
1156 prompt: "我是{role}。请带我了解当用户{action}时会发生什么,从 UI 一直到最终结果",
1157 slots: {
1158 role: "PM",
1159 action: "点击导出为 PDF"
1160 }
1161 },
1162 "plan-a-multi-file": {
1163 title: "在改动代码前规划多文件更改",
1164 teaches: "加上“暂时不要编辑”可以将探索与更改分开,让您在任何代码变动之前先看到方案。要让每个提示词都默认先做计划,请按 Shift+Tab 进入[计划模式](/docs/zh-CN/permission-modes#analyze-before-you-edit-with-plan-mode)。",
1165 prompt: "规划如何重构{target}以{goal}。列出需要修改的文件,但暂时不要编辑任何内容",
1166 slots: {
1167 target: "支付模块",
1168 goal: "支持多种货币"
1169 }
1170 },
1171 "draft-a-spec-by": {
1172 title: "通过访谈起草规范",
1173 teaches: "请 Claude 采访您,而不是自己编写规范。Claude 会向您提出结构化问题,直到需求完整为止,然后将结果写入文件。",
1174 next: "将您的访谈问题保存为 `/spec` skill,让每份规范都以相同方式开始",
1175 prompt: "我想构建{feature}。就实现、UX、边界情况和权衡向我提问,直到所有内容都覆盖到,然后将规范写入 SPEC.md",
1176 slots: {
1177 feature: "按工作区划分的速率限制"
1178 }
1179 },
1180 "turn-a-meeting-into": {
1181 title: "将会议转化为工单",
1182 teaches: "省去整理文字稿这一步。Claude 会从非结构化输入中提取行动项,并通过 [MCP](/docs/zh-CN/mcp) 直接写入您的跟踪器,因此您审查的是工单,而不是文字稿。",
1183 next: "将此保存为 `/tickets` skill",
1184 prompt: "阅读 {input} 并整理出行动项,然后在{tracker}中为每一项创建一个包含验收标准的工单",
1185 slots: {
1186 input: "@meeting-notes.md",
1187 tracker: "我们的问题跟踪器"
1188 }
1189 },
1190 "map-edge-cases-before": {
1191 title: "构建前梳理边界情况",
1192 teaches: "询问缺少什么,而不是已有什么。Claude 会列出只考虑理想路径的设计往往会遗漏的错误状态、空状态和边界情况。",
1193 prompt: "列出设计中需要覆盖的{feature}的错误状态、空状态和边界情况",
1194 slots: {
1195 feature: "文件上传流程"
1196 }
1197 },
1198 "turn-a-mockup-into": {
1199 title: "将设计稿转化为可运行的原型",
1200 teaches: "可点击的原型能回答静态设计稿无法回答的问题。把可运行的代码交给工程团队,而不是在文档中解释交互。",
1201 prompt: "这是一份设计稿。构建一个可以点击操作的可运行原型,与其中展示的布局和状态保持一致"
1202 },
1203 "implement-from-a-screenshot": {
1204 title: "根据截图实现并自行检查",
1205 teaches: "这为 Claude 提供了一个验证循环:它会渲染结果、与原始图像比较并反复迭代,无需您逐一指出差距。",
1206 next: "使用 `/goal` 让 Claude 持续迭代,直到截图一致",
1207 prompt: "实现这个设计,然后对结果截图,与原图进行比较,并修复所有差异"
1208 },
1209 "follow-an-existing-pattern": {
1210 title: "遵循现有模式",
1211 teaches: "指向您已经认可的代码。没有参考时,Claude 会默认采用通用的最佳实践;有了参考,它会匹配您的代码库实际使用的约定。",
1212 next: "请 Claude 将其遵循的模式写入 `CLAUDE.md`,以便以后的会话无需参考也能保持一致",
1213 prompt: "查看 {example} 的实现方式以理解其模式,然后用相同的方式构建 {new}",
1214 slots: {
1215 example: "现有的 webhook 处理程序",
1216 new: "支付 webhook 处理程序"
1217 }
1218 },
1219 "add-a-small-well": {
1220 title: "添加一个小而明确的功能",
1221 teaches: "说明输入和输出,而不是如何构建。Claude 会找到类似代码所在的位置,并在旁边添加您的代码。",
1222 prompt: "添加一个 {endpoint} 端点,返回{payload}",
1223 slots: {
1224 endpoint: "/health",
1225 payload: "应用版本和运行时长"
1226 }
1227 },
1228 "build-a-small-internal": {
1229 title: "从零构建一个小型内部工具",
1230 teaches: "您不需要项目、框架或构建步骤。描述工具并请 Claude 打开它,即可立即看到它运行。",
1231 prompt: "使用 HTML、CSS 和原生 JavaScript 创建一个{tool},然后在我的浏览器中打开它",
1232 slots: {
1233 tool: "包含三列的拖放式看板"
1234 }
1235 },
1236 "work-an-issue-end": {
1237 title: "端到端处理一个 issue",
1238 teaches: "给出 issue 编号,而不是摘要。Claude 会自行读取完整工单,因此您可能忘记提及的需求也会被考虑在内,并且它会在汇报前验证更改。",
1239 prompt: "阅读 issue #{issue},实现修复,并运行测试",
1240 slots: {
1241 issue: "312"
1242 }
1243 },
1244 "find-and-update-copy": {
1245 title: "在代码库中查找并更新文案",
1246 teaches: "要求查找变体,并说明要跳过的内容。Claude 会找出字面搜索会遗漏的措辞,同时不改动测试夹具和历史记录,因此您只需审查用户实际看到的文案。",
1247 prompt: "找到所有提到“{copy}”或类似说法的地方,逐一展示其上下文,然后将它们全部更新为“{new}”。不要改动测试和 changelog",
1248 slots: {
1249 copy: "免费注册",
1250 new: "开始免费试用"
1251 }
1252 },
1253 "draft-from-past-examples": {
1254 title: "根据以往示例起草文档",
1255 teaches: "指向存放已完成工作的文件夹,而不是描述您的风格。Claude 会从您已经发布的内容中学习结构和语气,因此初稿读起来就像出自您之手。",
1256 next: "将这种语气保存为 skill,让每份草稿都以此为起点",
1257 prompt: "阅读 {folder} 中的{examples}以学习其结构和语气,然后为{topic}起草一份新的",
1258 slots: {
1259 examples: "隐私影响评估",
1260 folder: "legal/pia/",
1261 topic: "新的分析集成"
1262 }
1263 },
1264 "write-tests-run-them": {
1265 title: "编写测试、运行测试、修复失败",
1266 teaches: "同时要求编写、运行和修复,让 Claude 持续迭代,无需停下来等待指示。",
1267 next: "运行 `/init`,让 Claude 自动了解您的测试命令",
1268 prompt: "为 {path} 编写测试,运行它们,并修复所有失败",
1269 slots: {
1270 path: "app/parsers/feed.py"
1271 }
1272 },
1273 "drive-implementation-from-tests": {
1274 title: "用测试驱动实现",
1275 teaches: "测试驱动开发:由测试来定义工作何时完成,Claude 会不断迭代实现,直到测试通过。",
1276 prompt: "先为{feature}编写测试,然后实现它,直到测试通过",
1277 slots: {
1278 feature: "密码重置流程"
1279 }
1280 },
1281 "fill-gaps-from-a": {
1282 title: "根据覆盖率报告填补空白",
1283 teaches: "指向覆盖率报告,而不是猜测哪些部分未被测试。Claude 会读取实际数据,并为最需要测试的文件编写测试。",
1284 next: "将此设置为 `/goal`,让 Claude 持续编写测试,直到达到覆盖率目标",
1285 prompt: "阅读 {report},为覆盖率最低的文件添加测试,直到每个文件都超过 {target}%",
1286 slots: {
1287 report: "coverage/coverage-summary.json",
1288 target: "80"
1289 }
1290 },
1291 "port-code-between-languages": {
1292 title: "将代码移植到另一种语言",
1293 teaches: "说明需要保留的内容,而不仅仅是目标语言。指明必须保持不变的 API 或行为,相当于给 Claude 一份契约,用来检验移植结果。",
1294 prompt: "将{source}移植到 {target},保持相同的{keep}",
1295 slots: {
1296 source: "这个 Python 模块",
1297 target: "Rust",
1298 keep: "公共 API 和测试行为"
1299 }
1300 },
1301 "generate-docs-for-code": {
1302 title: "为缺少文档的代码生成文档",
1303 teaches: "指明范围和格式。Claude 会找出缺失的内容,并匹配文件中已有的注释风格,让新文档与其余部分保持一致。",
1304 prompt: "找出没有 {format} 注释的{scope}并添加注释,与文件中已有的风格保持一致",
1305 slots: {
1306 scope: "src/auth/ 中的公共函数",
1307 format: "JSDoc"
1308 }
1309 },
1310 "migrate-a-pattern-across": {
1311 title: "在整个代码库中迁移模式",
1312 teaches: "描述旧模式和新模式。要求 Claude 先找出每一处需要修改的地方,这样调用位置会列在回复中,方便您检查是否有遗漏。对于涉及大量文件的迁移,请运行 [/batch](/docs/zh-CN/commands)。Claude 会将工作拆分为多个单元供您批准,然后由后台子代理进行更改。",
1313 prompt: "将所有内容从{from}迁移到{to}:先找出每一处需要修改的地方,然后进行修改",
1314 slots: {
1315 from: "旧的日志 API",
1316 to: "结构化日志记录器"
1317 }
1318 },
1319 "optimize-against-a-measurable": {
1320 title: "针对可量化目标进行优化",
1321 teaches: "说明指标和目标,能为 Claude 提供明确的完成标准。",
1322 next: "将此设置为 `/goal`,让 Claude 持续测量和迭代,直到达到目标数值",
1323 prompt: "优化{target},将{metric}从 {current} 降低到 {goal} 以下",
1324 slots: {
1325 target: "搜索查询",
1326 metric: "p95 延迟",
1327 current: "2s",
1328 goal: "500ms"
1329 }
1330 },
1331 "fix-a-precise-visual": {
1332 title: "修复精确的视觉问题",
1333 teaches: "精确的视觉反馈才能换来精确的修复。请说明具体的元素、尺寸和视口。",
1334 next: "添加预览工具,让 Claude 自行截图并验证修复",
1335 prompt: "在{viewport}上,{element}超出{container} {amount}。请修复。",
1336 slots: {
1337 element: "登录按钮",
1338 amount: "20px",
1339 container: "卡片边框",
1340 viewport: "移动端"
1341 }
1342 },
1343 "review-your-changes-before": {
1344 title: "提交前审查您的更改",
1345 teaches: "趁问题修复成本还低时发现它们。Claude 会完整读取更改过的文件,而不仅仅是 diff 行,因此能发现快速自查时容易遗漏的问题。",
1346 next: "运行 `/code-review`,一条命令完成同样的检查",
1347 prompt: "审查我尚未提交的更改,在我提交前标出任何看起来有风险的地方"
1348 },
1349 "review-a-pull-request": {
1350 title: "审查 Pull Request",
1351 teaches: "Claude 审查时会结合整个代码库的上下文,而不仅仅是 diff。它会读取更改的代码及其调用的内容,因此能发现只看 diff 的审查会遗漏的问题。",
1352 next: "运行 `/code-review <pr#>` 一条命令完成,或为每个 PR 启用 Code Review",
1353 prompt: "审查 PR #{pr},总结更改内容,然后列出任何疑虑",
1354 slots: {
1355 pr: "247"
1356 }
1357 },
1358 "review-infrastructure-changes-before": {
1359 title: "应用前审查基础设施更改",
1360 teaches: "plan 输出内容密集,难以快速浏览。将其粘贴进来,即可在应用之前获得一份通俗易懂的摘要,了解实际将发生哪些更改。",
1361 prompt: "这是我的 Terraform plan 输出。它会做什么?其中有没有会导致问题的内容?"
1362 },
1363 "run-a-security-review": {
1364 title: "使用子代理运行安全审查",
1365 teaches: "[子代理](/docs/zh-CN/sub-agents)会在自己的上下文窗口中运行审计并汇报摘要,因此冗长的安全审查不会占满您的主会话。内置的通用子代理无需额外设置即可处理此任务。",
1366 next: "设置一个专用的安全审查子代理,供整个团队使用",
1367 prompt: "使用子代理审查 {path} 中的安全问题,并报告其发现",
1368 slots: {
1369 path: "src/api/"
1370 }
1371 },
1372 "review-content-before-sending": {
1373 title: "在正式审查前发现问题",
1374 teaches: "在他人投入时间之前先过一遍。指明您希望检查的关注点,让审查更有针对性,然后修复发现的问题,再发送一份更完善的草稿。",
1375 next: "将您的审查清单保存为整个团队都能运行的 skill",
1376 prompt: "审查 {file} 中的{concerns},并列出在提交给{reviewer}之前需要修复的内容",
1377 slots: {
1378 file: "launch-post.md",
1379 concerns: "无依据的说法、缺失的出处标注以及品牌规范问题",
1380 reviewer: "法务"
1381 }
1382 },
1383 "course-correct-a-wrong": {
1384 title: "纠正错误的方向",
1385 teaches: "指出 Claude 遗漏的约束,而不只是说它错了。具体的原因能给 Claude 一个在重试时需要满足的明确约束,而不是再次猜测。",
1386 next: "按两次 `Esc` 打开回退菜单,恢复代码和对话,让重试从干净的状态开始",
1387 prompt: "这不对:{feedback}。换一种方法试试",
1388 slots: {
1389 feedback: "函数签名需要保持向后兼容"
1390 }
1391 },
1392 "narrow-the-scope-of": {
1393 title: "缩小更改的范围",
1394 teaches: "当方向正确但更改过于宽泛时,请 Claude 保留其中一部分,而不是全部回退。明确的边界能避免一个小修复演变成一次重构。",
1395 prompt: "改动太多了。只保留对{scope}的更改,撤销其他编辑",
1396 slots: {
1397 scope: "src/forms/ 中的验证逻辑"
1398 }
1399 },
1400 "turn-a-correction-into": {
1401 title: "将纠正转化为规则",
1402 teaches: "在聊天中的纠正不会与团队共享。而项目 [CLAUDE.md](/docs/zh-CN/memory) 中的规则在您提交后即可共享,Claude 会在每个会话开始时读取它。",
1403 next: "打开 `/memory` 查看 Claude 写入的内容",
1404 prompt: "反复出现{mistake}的问题。请在 CLAUDE.md 中添加一条规则,避免再次发生",
1405 slots: {
1406 mistake: "在本项目使用具名导出的情况下使用默认导出"
1407 }
1408 },
1409 "resolve-merge-conflicts": {
1410 title: "解决合并冲突",
1411 teaches: "说明您想要的最终状态,而不是要保留哪些标记。要求说明理由,能让合并结果可审查,而不是一个黑盒。",
1412 prompt: "解决此分支中的合并冲突,并说明从每一方各保留了哪些内容"
1413 },
1414 "commit-with-a-generated": {
1415 title: "使用生成的提交信息进行提交",
1416 teaches: "让 Claude 根据 diff 生成提交信息。它会匹配您仓库现有的提交风格。",
1417 prompt: "提交这些更改,并附上一条总结我所做工作的提交信息"
1418 },
1419 "open-a-pull-request": {
1420 title: "根据工单创建 Pull Request",
1421 teaches: "省去在跟踪器、编辑器和 GitHub 之间来回切换。一个提示词即可读取需求、完成更改并创建 PR。",
1422 prompt: "在{tracker}中找到关于{topic}的工单,并创建一个实现它的 PR",
1423 slots: {
1424 tracker: "我们的问题跟踪器",
1425 topic: "登录超时"
1426 }
1427 },
1428 "draft-release-notes-from": {
1429 title: "根据 git 历史起草发布说明",
1430 teaches: "给出两个参考点以及您想要的结构。Claude 会读取两者之间的提交日志,并起草一份可供您编辑的更新日志。",
1431 next: "将此保存为 `/changelog` skill",
1432 prompt: "比较 {from} 和 {to},按功能、修复和破坏性变更分组起草发布说明",
1433 slots: {
1434 from: "v2.3.0",
1435 to: "v2.4.0"
1436 }
1437 },
1438 "write-a-ci-workflow": {
1439 title: "编写 CI 工作流",
1440 teaches: "描述它应在何时运行以及应做什么;系统会为您生成 YAML,并与项目的构建和测试命令相匹配。",
1441 prompt: "编写一个 GitHub Actions 工作流,在每次推送到 {branch} 时{steps}",
1442 slots: {
1443 steps: "运行测试并部署到预发布环境",
1444 branch: "main"
1445 }
1446 },
1447 "find-and-fix-a": {
1448 title: "找到并修复失败的测试",
1449 teaches: "描述症状即可;您无需知道是哪个文件出了问题。Claude 会运行测试查看失败情况,追踪到源代码中,并进行修复。",
1450 prompt: "{test} 测试失败了,找出原因并修复",
1451 slots: {
1452 test: "UserAuth"
1453 }
1454 },
1455 "investigate-a-reported-error": {
1456 title: "调查报告的错误",
1457 teaches: "描述症状和位置;Claude 会读取相关代码路径并追踪可能的原因。如果您有堆栈跟踪或日志,请一并粘贴。",
1458 next: "在您的运行手册中放置一个深层链接,打开 Claude 时自动预填此提示词",
1459 prompt: "用户在 {where} 上遇到了{symptom}。请调查并告诉我发生了什么",
1460 slots: {
1461 symptom: "500 错误",
1462 where: "/api/settings"
1463 }
1464 },
1465 "fix-a-build-error": {
1466 title: "从根源修复构建错误",
1467 teaches: "要求修复根本原因并进行验证,可以避免只是压制错误而未真正修复的表面补丁。",
1468 prompt: "这是一个构建错误。修复根本原因并验证构建成功"
1469 },
1470 "investigate-a-production-incident": {
1471 title: "调查生产事件",
1472 teaches: "列出需要关联分析的证据来源,而不是要采取的步骤。Claude 会综合读取日志、git 历史和配置,以缩小原因范围。",
1473 next: "通过 MCP 连接您的错误跟踪器或日志存储",
1474 prompt: "{symptom}。检查日志、最近的部署和配置更改,然后告诉我最可能的原因",
1475 slots: {
1476 symptom: "结账端点从一小时前开始返回 500"
1477 }
1478 },
1479 "query-logs-in-plain": {
1480 title: "用自然语言查询日志",
1481 teaches: "直接提出问题,而不是编写 SQL。Claude 会构建查询、在您连接的日志上运行,并同时展示查询语句和结果,方便您核对实际运行的内容。",
1482 prompt: "显示{scope}在{timeframe}内的所有{events}。编写查询、运行它,并告诉我哪些地方值得注意",
1483 slots: {
1484 events: "登录失败",
1485 scope: "认证服务",
1486 timeframe: "过去 24 小时"
1487 }
1488 },
1489 "diagnose-from-a-console": {
1490 title: "根据控制台截图进行诊断",
1491 teaches: "云控制台会向您展示问题,但不会给出修复命令。Claude 会读取截图,并将仪表板内容转换为需要运行的 kubectl、gcloud 或 aws 命令。",
1492 prompt: "这是{console}的截图。请带我分析{resource}为什么失败,并给出修复它的确切命令",
1493 slots: {
1494 console: "我们的 Kubernetes 仪表板",
1495 resource: "这个 pod"
1496 }
1497 },
1498 "analyze-a-data-file": {
1499 title: "分析数据文件",
1500 teaches: "一次性的问题不需要一次性的脚本。指向项目文件夹中的文件,Claude 会直接读取它、找出规律,并将输出写到您指定的位置。",
1501 next: "通过 MCP 连接数据源,而不是导出文件",
1502 prompt: "读取 {file},总结关键规律,并将结果写入{output}",
1503 slots: {
1504 file: "@reports/q1-signups.csv",
1505 output: "一个带图表的 HTML 页面,然后在我的浏览器中打开它"
1506 }
1507 },
1508 "generate-variations-from-performance": {
1509 title: "根据效果数据生成变体",
1510 teaches: "在一开始就说明约束,让生成内容不超出限制。Claude 会读取指标,挑选需要替换的内容,并生成符合要求的替代方案。",
1511 next: "通过 MCP 连接广告平台,而不是导出文件",
1512 prompt: "读取 {file},找出表现不佳的{items},并生成 {n} 个不超过 {limit} 个字符的新变体",
1513 slots: {
1514 file: "@ads-performance.csv",
1515 items: "标题",
1516 n: "20",
1517 limit: "90"
1518 }
1519 },
1520 "turn-a-recurring-task": {
1521 title: "将重复任务转化为 skill",
1522 teaches: "只需说明一次步骤,即可作为命令反复使用。Claude 会编写一个团队中任何人都能运行的 [skill](/docs/zh-CN/skills)。",
1523 prompt: "为此项目创建一个 /{name} skill,用于{steps}",
1524 slots: {
1525 name: "ship",
1526 steps: "运行 linter 和测试,然后起草提交信息"
1527 }
1528 },
1529 "add-a-hook-for": {
1530 title: "为重复行为添加 hook",
1531 teaches: "hook 能让某个行为自动发生,而不必每次都记得提出要求。描述触发条件和操作,Claude 就会编写 [hook](/docs/zh-CN/hooks) 配置。",
1532 prompt: "编写一个 hook,在每次{event}后{action}",
1533 slots: {
1534 action: "运行 prettier",
1535 event: "编辑 .ts 或 .tsx 文件"
1536 }
1537 },
1538 "connect-a-tool-with": {
1539 title: "使用 MCP 连接工具",
1540 teaches: "一次性连接数据源,而不是每个会话都粘贴数据。完成 [MCP](/docs/zh-CN/mcp) 设置后,当您询问相关内容时,Claude 会直接从该工具读取数据。",
1541 prompt: "通过 MCP 连接{server},以便你能直接读取其{data}",
1542 slots: {
1543 server: "我们的错误跟踪器",
1544 data: "堆栈跟踪"
1545 }
1546 },
1547 "capture-what-to-remember": {
1548 title: "记录下次需要记住的内容",
1549 teaches: "趁还没忘记时询问。Claude 知道它在本次会话中需要摸索出哪些内容,并会建议添加到 [CLAUDE.md](/docs/zh-CN/memory) 的条目,让下一个会话从这些上下文开始。",
1550 prompt: "总结我们在本次会话中做了什么,并建议向 CLAUDE.md 添加哪些内容"
1551 }
1552};
1553
1554<PromptLibrary text={text} labels={labels} tagLabels={tagLabels} phaseLabels={phaseLabels} sourceLabels={sourceLabels} catLabels={catLabels} />
1555
1556<h2 id="what-makes-these-prompts-work">
1557 这些提示词为什么有效
1558</h2>
1559 14
1560上面的提示词共享一些模式。识别它们有助于你将此处的任何提示词调整到你自己的任务。15上面的提示词共享一些模式。识别它们有助于你将此处的任何提示词调整到你自己的任务。
1561 16
1597 52
1598有关每个模式的更多信息,请参阅[最佳实践](/docs/zh-CN/best-practices)。53有关每个模式的更多信息,请参阅[最佳实践](/docs/zh-CN/best-practices)。
1599 54
1600<h2 id="where-these-come-from">55## 这些来自哪里
1601 这些来自哪里
1602</h2>
1603 56
1604这些提示词基于已发布的 Anthropic 资源中的模式。每张卡片都链接到其来源:57这些提示词基于已发布的 Anthropic 资源中的模式。每张卡片都链接到其来源:
1605 58
1610 63
1611有关这些模式的视频演练,请参阅 [Claude Academy](https://academy.claude.com/) 上的免费 [Claude Code in Action](https://academy.claude.com/courses/claude-code-in-action) 课程。64有关这些模式的视频演练,请参阅 [Claude Academy](https://academy.claude.com/) 上的免费 [Claude Code in Action](https://academy.claude.com/courses/claude-code-in-action) 课程。
1612 65
1613<h2 id="related-resources">66## 相关资源
1614 相关资源
1615</h2>
1616 67
1617此页面上的提示词是起点。一旦一个对你的项目有效,下一步是使其可重复:将其保存为 [技能](/docs/zh-CN/skills),以便团队中的任何人都可以将其作为 `/command` 运行,并在 [CLAUDE.md](/docs/zh-CN/memory) 中记录 Claude 学到的约定,以便每个会话都以该上下文开始,而不是 Claude 重新学习它。对于更大或更危险的更改,[Plan Mode](/docs/zh-CN/permission-modes#analyze-before-you-edit-with-plan-mode) 在任何编辑发生前显示文件列表。68此页面上的提示词是起点。一旦一个对你的项目有效,下一步是使其可重复:将其保存为 [技能](/docs/zh-CN/skills),以便团队中的任何人都可以将其作为 `/command` 运行,并在 [CLAUDE.md](/docs/zh-CN/memory) 中记录 Claude 学到的约定,以便每个会话都以该上下文开始,而不是 Claude 重新学习它。对于更大或更危险的更改,[Plan Mode](/docs/zh-CN/permission-modes#analyze-before-you-edit-with-plan-mode) 在任何编辑发生前显示文件列表。
1618 69