Prompt files are reusable, Markdown-based instructions that can be executed on-demand to perform tasks like generating code, running code reviews, or scaffolding components. They help standardize workflows and ensure consistent AI behavior.
🧾 Prompt File Structure (*.prompt.md
)
✅ Supports:
-
Markdown formatting
-
Variables like
${file}
,${selection}
,${input:formName}
-
Links to:
-
Workspace files:
[index](../index.ts)
-
Instruction files:
[TS Guidelines](../instructions/ts.instructions.md)
-
Other prompts:
[Base Prompt](./base.prompt.md)
-
📁 Where to Store Prompt Files
Scope | Path | Notes |
---|---|---|
Workspace | .github/prompts/ | Shared within project repo |
User Profile | Stored in your VS Code profile | Available across all workspaces |
🔁 Use Settings Sync to sync prompt files across devices.
🚀 How to Use a Prompt File
Method | Description |
---|---|
/prompt-name in chat | Run a prompt quickly (e.g., /create-form ) |
/prompt-name:field=value | Pass input variables (e.g., /create-form:formName=Login ) |
Command Palette | Run Chat: Run Prompt and pick a file |
Editor Play Button | Open .prompt.md file and hit ▶️ |
🔧 Enable & Create Prompt Files
-
Enable setting (optional but recommended):
-
Create a prompt:
-
Open Chat view →
Configure Chat > Prompt Files > New prompt file
-
Or use Command Palette:
Chat: New Prompt File
-
-
Choose scope:
-
Workspace (in
.github/prompts
) -
User (VS Code profile)
-
🧪 Example Prompt Files
📦 Generate a React Form Component
🔐 REST API Security Review
🧠 Prompt Variables
Variable | Example | Purpose |
---|---|---|
${selection} | Selected code in editor | Context-sensitive prompts |
${file} , ${fileBasename} | Current file info | File-specific generation |
${input:formName} | User input (e.g., LoginForm ) | Interactive prompts |
${workspaceFolder} | Full path to workspace | Dynamic referencing |
💡 Tips for Writing Effective Prompt Files
-
Be specific about the task and expected output format
-
Reference instruction files instead of repeating content
-
Use variables for flexibility
-
Test and iterate using the editor play button
-
Keep descriptions short and clear
-
Use Markdown lists and formatting to structure tasks
-
Organize prompts by domain (e.g.,
react-form.prompt.md
,api-review.prompt.md
)
🔗 Related Features
-
✅ Custom Instructions — Default behavior and guidelines
-
🎯 Custom Chat Modes — Different personas or interaction styles
-
🔌 Configure Tools — Add tool access (e.g., repo scanner)
0 件のコメント:
コメントを投稿