🎯 Trigger Mapping
| User Input Trigger Phrases | AI Action to Perform |
|---|
| "create skill" / "new skill" / "add skill" / "initialize skill" | Execute in [Creation Mode] |
Creation Mode
Execution Steps
| Step | Action | Specific Command/Operation |
|---|
| 1 | Ask for Requirements | Run to inquire about the skill's function, usage scenarios and trigger conditions |
| 2 | Initialize Directory | Run to execute python scripts/init_skill.py <skill-name> --path <output-dir>
|
| 3 | Read and Edit SKILL | Run to read the generated SKILL.md, then run to fill in the function description and trigger conditions |
| 4 | Validate Structure | Run to execute python scripts/quick_validate.py <skill-directory>
|
Output Results
Example Output on Success:
✅ Skill '{skill-name}' created successfully
📁 Directory Structure:
.trae/skills/{skill-name}/
├── SKILL.md # Skill documentation (template filled)
├── scripts/ # Script directory
│ └── example.py # Sample script
└── references/ # Reference documentation directory
└── README.md # Reference instructions
📝 Next Steps:
Run `Read` to open SKILL.md, then edit the function description and trigger conditions based on user requirements
Example Output on Failure:
❌ Skill creation failed
Error Reason: {specific error message}
Suggested Solution: {targeted solution}
Error Handling
| Error Scenario | Error Manifestation | Handling Method |
|---|
| Directory Already Exists | reports directory exists error | Run to check directory content; proceed if empty, ask user whether to overwrite if there is content |
| Script Execution Failure | Python returns non-zero exit code | Check Python version and dependency installation, retry execution |
| Insufficient Permissions | File write access denied | Check directory permissions, suggest user to change output directory |
| Invalid Skill Name | Contains uppercase letters or special characters | Prompt user to modify to kebab-case format (e.g., ) |
Core Principles
Concise is Key
The context window is a shared resource. Skills share the context window with system prompts, conversation history, metadata of other skills, and user requests.
Default Assumption: AI is already intelligent. Only add information that the AI doesn't have. Question every piece of information: "Does the AI really need this explanation?" "Is this text worth its token cost?"
Prioritize concise examples over lengthy explanations.
Set Appropriate Flexibility
Match the level of detail to the fragility and variability of the task:
| Flexibility Level | Applicable Scenarios | Form |
|---|
| High Flexibility | Multiple valid approaches exist, decisions depend on context, heuristic guidance is needed | Text-based instructions |
| Medium Flexibility | Preferred patterns exist, some variations are allowed, configurations affect behavior | Pseudocode or scripts with parameters |
| Low Flexibility | Operations are fragile and error-prone, consistency is critical, specific sequences must be followed | Specific scripts with few parameters |
AI-Friendly
Skills are for AI use - ensure that AI can accurately understand and execute them. Created skills must meet the following AI-friendly standards:
| Check Item | Requirement | Description |
|---|
| Clear description | Mandatory | The description in frontmatter must include function and trigger conditions |
| Clear Instructions | Mandatory | Use imperative sentences (run, execute, call, etc.) instead of vague suggestions |
| Specific Examples | Mandatory | Provide code examples or user request examples, AI needs to know how to do it specifically |
| Decision Logic | Recommended | For complex tasks, provide conditional judgments or decision trees to help AI make correct choices |
| Output Format | Mandatory | Clearly specify what content the skill should output |
| Error Handling | Recommended | Explain abnormal situations and boundary handling |
| Avoid Long Paragraphs | Recommended | Paragraphs over 500 characters make it difficult to extract key information; use lists or tables |
| File Reference Explanation | Mandatory | Referenced files must have Markdown link descriptions |
Optimization Tips:
- Imagine you are the AI; after reading the skill, can you answer: When to use it? How to use it? What to output?
- Use specific rather than abstract vocabulary
- Provide clear operation steps instead of vague guidance
- Provide decision processes for complex scenarios
Key Specifications for Agent Skills
Directory Structure
skill-name/
├── SKILL.md # Required: Skill documentation
├── scripts/ # Optional: Executable code
├── references/ # Optional: Reference documentation
└── assets/ # Optional: Templates, resources
Files that should not be included: Auxiliary documents such as README.md, INSTALLATION_GUIDE.md, CHANGELOG.md.
SKILL.md Format
Required Frontmatter Metadata:
yaml
---
name: skill-name
description: Function description. When to use: When the user says/needs/encounters...
---
Rules for name Field
- 1-64 characters, can only contain lowercase letters, numbers and hyphens
- Cannot start or end with a hyphen, cannot contain consecutive hyphens
- Must match the parent directory name
Rules for description Field
- 1-1024 characters
- Must include two parts separated by :
- Function Description - What this skill does
- When to Use - What the user says to trigger this skill
- All trigger condition information should be placed in the description - Do not put it in the main body
Good Example:
yaml
description: Analyze and optimize documentation quality issues of other Skills, including checks for frontmatter format, progressive disclosure structure, etc. When to use: When the user says "optimize this skill", "check skill quality", "review skill".
Bad Examples:
yaml
# ❌ Missing "When to use" section
description: Analyze and optimize documentation quality issues of Skills
# ❌ Uses "Trigger Conditions" instead of "When to use"
description: Analyze Skill quality issues. Trigger Conditions: When the user says to optimize skill
Progressive Disclosure Design
Skills use a three-level loading system to efficiently manage context:
- Metadata (name + description) - Always in context (approx. 100 words)
- SKILL.md Main Body - Loaded when the skill is triggered (recommended < 5000 words, < 500 lines)
- Bundled Resources - Loaded by AI on demand
Key Principle: When a skill supports multiple variants, frameworks or options, only retain the core workflow and selection guidance in SKILL.md. Move variant-specific details to separate reference files.
Progressive Disclosure Patterns
Pattern 1: Advanced Guide + References
markdown
## Quick Start
[Core Code Example]
## Advanced Features
- **Form Filling**: See complete guide in [FORMS.md](references/FORMS.md)
- **API Reference**: See [REFERENCE.md](references/REFERENCE.md)
Pattern 2: Organized by Domain
skill-name/
├── SKILL.md (Overview and Navigation)
└── references/
├── finance.md
├── sales.md
└── product.md
Important Guidelines:
- Avoid deeply nested references; keep reference files in the first-level subdirectory of SKILL.md
- Avoid duplication: Information should exist only in SKILL.md or reference files, not both
SKILL.md Structure Patterns
Choose the structure that best fits the skill's purpose:
| Pattern | Applicable Scenarios | Structure |
|---|
| Workflow-Based | Sequential processes | → ## Workflow Decision Tree
→ ... |
| Task-Based | Tool collections | → → ... |
| Reference/Guide | Standards or specifications | → → |
| Capability-Based | Integrated systems | → → ... |
Patterns can be mixed and matched.
Skill Creation Process
Execute the following steps in order:
Skill Creation Process
Execute the following steps in order:
| Step | Action | Specific Command/Operation |
|---|
| 1 | Ask for Functional Requirements | Run to inquire about skill function, usage examples and trigger conditions |
| 2 | Plan Reusable Resources | Analyze requirements, determine required scripts, references, assets |
| 3 | Initialize Skill Directory | Run to execute python scripts/init_skill.py <skill-name> --path <output-directory>
|
| 4 | Read SKILL.md | Run to read the generated .trae/skills/{skill-name}/SKILL.md
|
| 5 | Edit Function Description | Run to fill in description, trigger conditions and execution steps |
| 6 | Create Scripts | If scripts are needed, run to create them in the directory |
| 7 | Create Reference Documents | If reference documents are needed, run to create them in the directory |
| 8 | Validate Structure | Run to execute python scripts/quick_validate.py <skill-directory>
|
| 9 | Test and Iterate | Based on validation results, run to fix issues |
Workflow Patterns
Detailed workflow patterns (sequence, condition, decision tree, loop, error handling) can be found in Workflow Patterns Documentation.
Output Patterns
Detailed output patterns (templates, examples, checklists) can be found in Output Patterns Documentation.
Bundled Resources
scripts/
Executable code (Python/Bash/etc.) used for tasks requiring deterministic reliability or repeated rewriting.
- When to include: When the same code is repeatedly rewritten or requires deterministic reliability
- Benefits: Token-efficient, deterministic, can be executed without loading into context
- AI-Friendly Principles: The input and output of the code should be AI-friendly
- Input: Support command-line parameters, environment variables or structured data (JSON/YAML), avoid interactive prompts
- Output: Use structured formats (JSON/YAML/table), include clear field names, avoid natural language descriptions that need parsing
- Error Handling: Return standard exit codes, output error messages to stderr, output successful results to stdout
references/
Documents and reference materials designed to be loaded into context on demand.
- When to include: Detailed documents that AI should reference when working
- Benefits: Keep SKILL.md concise, only load when needed
assets/
Files not intended to be loaded into context, but used in the output generated by AI.
- When to include: Files that the skill needs to use in the final output (templates, images, etc.)
- Benefits: Separate output resources from documentation
Utility Scripts
| Script | Purpose | Command |
|---|
| init_skill.py | Initialize new skill | python scripts/init_skill.py <skill-name> --path <output-dir>
|
| skill_templates.py | Template definition module | Called by init_skill.py, contains templates for SKILL.md and sample files |
| quick_validate.py | Quick validation | python scripts/quick_validate.py <skill-directory>
|
| create-skill.py | Create complete skill | python scripts/create-skill.py <skill-name>
|
Creation Example
User Input: "Create a skill to process PDFs"
Execution Steps:
| Step | Action | Specific Command/Operation |
|---|
| 1 | Ask for Scenarios | Run to inquire about specific usage scenarios (text extraction, form filling, merging, etc.) |
| 2 | Plan Content | Analyze requirements, determine that Python scripts are needed to process PDFs |
| 3 | Initialize Directory | Run to execute python scripts/init_skill.py pdf-processor --path ./skills
|
| 4 | Read SKILL.md | Run to read ./skills/pdf-processor/SKILL.md
|
| 5 | Edit Description | Run to fill in description as "Process PDF files. When to use: When the user says to process PDFs" |
| 6 | Create Processing Script | Run to create |
| 7 | Validate Structure | Run to execute python scripts/quick_validate.py ./skills/pdf-processor
|