AgentSkillsCN

prompt-writing

为AI编码代理及其子代理的委托任务生成高效提示。在为任务工具委托编写提示、创建代理指令,或设计多步骤工作流时,请主动使用此技能。当您需要将复杂任务委派给子代理,或为系统编写提示时,务必使用此技能。

SKILL.md
--- frontmatter
name: prompt-writing
description: Creates effective prompts for AI coding agents and subagent delegation. Use PROACTIVELY when writing prompts for Task tool delegation, creating agent instructions, or designing multi-step workflows. MUST BE USED when delegating complex tasks to subagents or writing system prompts.
allowed-tools: ["Read", "Write", "Edit", "Grep", "Glob"]

Prompt Writing Skill

Overview

Core Principle: Context completeness over brevity. Agents cannot infer what you don't provide.

Target Users:

  • Claude Code delegating to subagents via Task tool
  • UI agents that need to generate prompts
  • Engineers writing system prompts or agent instructions

The CLEAR Framework

Use this mnemonic for every prompt you write:

LetterComponentPurposeKey Question
CContextBackground informationWhat does the agent need to know?
LLimitationsConstraints, prohibitionsWhat should NOT be done?
EExpectationsOutput format, success criteriaWhat exactly should be returned?
AActionsStep-by-step instructionsWhat steps to follow?
RResourcesFiles, tools, referencesWhat materials are available?

C - Context

Complete background: project state, environment, history. Include file paths, versions, prior decisions.

L - Limitations

Explicit boundaries: DO NOT modify X, use only Y, forbidden patterns, compliance requirements.

E - Expectations

Exact output format: markdown structure, JSON schema, where to save, success criteria checklist.

A - Actions

Numbered steps, validation checkpoints, decision points, error handling guidance.

R - Resources

Required reading (file paths), available tools, reference implementations, examples.

Full guide with examples: reference/prompt-anatomy.md


Context Patterns

Critical Insight

Subagents have NO conversation history. Each invocation is completely fresh. They cannot infer context.

Three Strategies

StrategyWhen to UseHow
File-BasedMulti-step workflowsSave to file, pass path to next agent
EmbeddedSmall contextsInclude all info directly in prompt
LayeredLarge contextsSummary + references for deep-dive

State Transfer Pattern

code
Agent 1 → Save results to `.claude/state/results/agent-{timestamp}.md`
Agent 2 → Read from that file path

Full patterns: reference/context-patterns.md


Output Format Quick Reference

PatternUse CaseKey Feature
Structured MarkdownComprehensive resultsTables, sections, test output
Binary VerdictReview/validationPASS/FAIL first, then details
ChecklistMulti-requirementProgress tracking with status
CondensedSubagent responsesMax 3 findings, no verbose output

Delivery Patterns

  • State directory: .claude/state/results/[agent]-[timestamp].md
  • Project output: output/[task-id]/[artifact].md
  • Inline: Return directly (use for summaries only)

Full templates: reference/output-specifications.md


Quality Checklist

Before sending any prompt, verify:

Context (C)

  • All background information included?
  • File paths explicit and complete?
  • No assumptions about prior knowledge?

Limitations (L)

  • Constraints clearly stated?
  • Prohibited actions explicit?
  • Scope boundaries defined?

Expectations (E)

  • Output format specified exactly?
  • Success criteria measurable?
  • Delivery location defined?

Actions (A)

  • Steps numbered and sequential?
  • Validation checkpoints included?
  • Error handling guidance provided?

Resources (R)

  • Required files listed with paths?
  • Available tools mentioned?
  • Examples provided where helpful?

Subagent-Specific

  • No implicit context assumptions?
  • State transfer mechanism defined?
  • Output format prevents overload?

Anti-Patterns Quick Reference

Anti-PatternProblemSolution
Context AmnesiaAssumes agent remembersEmbed all context explicitly
Vague Expectations"Give me a good result"Specify exact format
Implicit Constraints"Follow best practices"List specific requirements
Unbounded Scope"Improve the code"Define precise boundaries
Missing Resources"Check the docs"Provide file paths
Output OverloadNo format limitsRequest condensed response

Full examples with solutions: reference/anti-patterns.md


Templates

Ready-to-use templates for common scenarios:

TemplatePurpose
templates/subagent-delegation.mdTask tool delegation
templates/code-task.mdImplementation tasks
templates/research-task.mdResearch/exploration
templates/review-task.mdCode review/validation

Quick Start

  1. Choose template from templates/ matching your task type
  2. Fill CLEAR sections systematically
  3. Run checklist to verify completeness
  4. Execute the prompt
  5. Iterate if results don't match expectations

Remember: More context is almost always better. When in doubt, include it.


Troubleshooting

ProblemLikely CauseSolution
Irrelevant resultsInsufficient contextAdd explicit file references, examples
Wrong formatVague specificationProvide template with placeholders
Unwanted changesMissing constraintsAdd explicit DO NOT statements
Incomplete taskUnclear success criteriaAdd specific acceptance criteria
Agent asks questionsAmbiguous requirementsMake all decisions upfront

Reference Documentation