@abarcenas/ai-workflow-template 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/.github/agents/implementation-plan.agent.md +192 -0
  2. package/.github/agents/plan.agent.md +135 -0
  3. package/.github/agents/research-spike.agent.md +204 -0
  4. package/.github/instructions/agent-safety.instructions.md +98 -0
  5. package/.github/instructions/agent-skill.instructions.md +272 -0
  6. package/.github/instructions/agent.instructions.md +1068 -0
  7. package/.github/instructions/ai-prompt-engineering-safety.instructions.md +991 -0
  8. package/.github/instructions/angular.instructions.md +116 -0
  9. package/.github/instructions/context7.instructions.md +109 -0
  10. package/.github/instructions/go.instructions.md +374 -0
  11. package/.github/instructions/html-to-css-guide.instructions.md +104 -0
  12. package/.github/instructions/instructions.instructions.md +264 -0
  13. package/.github/instructions/markdown.instructions.md +51 -0
  14. package/.github/instructions/memory-bank.instructions.md +322 -0
  15. package/.github/instructions/nodejs-vitest.instructions.md +34 -0
  16. package/.github/instructions/playwright-typescript.instructions.md +88 -0
  17. package/.github/instructions/prompt.instructions.md +99 -0
  18. package/.github/instructions/security-owasp.instructions.md +59 -0
  19. package/.github/instructions/shell.instructions.md +132 -0
  20. package/.github/instructions/task-implementation.instructions.md +203 -0
  21. package/.github/instructions/typescript.instructions.md +114 -0
  22. package/.github/prompts/copilot-instructions-blueprint-generator.prompt.md +317 -0
  23. package/.github/prompts/documentation-writer.prompt.md +46 -0
  24. package/.github/prompts/editconfig.prompt.md +64 -0
  25. package/.github/prompts/playwright-explore.prompt.md +39 -0
  26. package/.github/prompts/playwright-generate-test.prompt.md +39 -0
  27. package/.github/skills/agent-governance/SKILL.md +572 -0
  28. package/.github/skills/boost-prompt/SKILL.md +25 -0
  29. package/.github/skills/chrome-devtools/SKILL.md +97 -0
  30. package/.github/skills/context-map/SKILL.md +57 -0
  31. package/.github/skills/conventional-commit/SKILL.md +72 -0
  32. package/.github/skills/create-readme/SKILL.md +21 -0
  33. package/.github/skills/editorconfig/SKILL.md +63 -0
  34. package/.github/skills/gh-cli/SKILL.md +2188 -0
  35. package/.github/skills/git-commit/SKILL.md +124 -0
  36. package/.github/skills/github-issues/SKILL.md +134 -0
  37. package/.github/skills/github-issues/references/templates.md +110 -0
  38. package/.github/skills/microsoft-docs/SKILL.md +114 -0
  39. package/.github/skills/playwright-explore-website/SKILL.md +17 -0
  40. package/.github/skills/playwright-generate-test/SKILL.md +17 -0
  41. package/.github/skills/polygot-test-agent/SKILL.md +171 -0
  42. package/.github/skills/polygot-test-agent/unit-test-genearation.prompt.md +155 -0
  43. package/.github/skills/prompt-builder/SKILL.md +159 -0
  44. package/.github/workflows/npm-publish.yml +25 -0
  45. package/README.md +111 -0
  46. package/package.json +32 -0
  47. package/scripts/bump-version.js +29 -0
  48. package/scripts/sync.js +122 -0
@@ -0,0 +1,1068 @@
1
+ ---
2
+ description: "Guidelines for creating custom agent files for GitHub Copilot"
3
+ applyTo: "**/*.agent.md"
4
+ ---
5
+
6
+ # Custom Agent File Guidelines
7
+
8
+ Instructions for creating effective and maintainable custom agent files that provide specialized expertise for specific development tasks in GitHub Copilot.
9
+
10
+ ## Project Context
11
+
12
+ - Target audience: Developers creating custom agents for GitHub Copilot
13
+ - File format: Markdown with YAML frontmatter
14
+ - File naming convention: lowercase with hyphens (e.g., `test-specialist.agent.md`)
15
+ - Location: `.github/agents/` directory (repository-level) or `agents/` directory (organization/enterprise-level)
16
+ - Purpose: Define specialized agents with tailored expertise, tools, and instructions for specific tasks
17
+ - Official documentation: https://docs.github.com/en/copilot/how-tos/use-copilot-agents/coding-agent/create-custom-agents
18
+
19
+ ## Required Frontmatter
20
+
21
+ Every agent file must include YAML frontmatter with the following fields:
22
+
23
+ ```yaml
24
+ ---
25
+ description: "Brief description of the agent purpose and capabilities"
26
+ name: "Agent Display Name"
27
+ tools: ["read", "edit", "search"]
28
+ model: "Claude Sonnet 4.5"
29
+ target: "vscode"
30
+ infer: true
31
+ ---
32
+ ```
33
+
34
+ ### Core Frontmatter Properties
35
+
36
+ #### **description** (REQUIRED)
37
+
38
+ - Single-quoted string, clearly stating the agent's purpose and domain expertise
39
+ - Should be concise (50-150 characters) and actionable
40
+ - Example: `'Focuses on test coverage, quality, and testing best practices'`
41
+
42
+ #### **name** (OPTIONAL)
43
+
44
+ - Display name for the agent in the UI
45
+ - If omitted, defaults to filename (without `.md` or `.agent.md`)
46
+ - Use title case and be descriptive
47
+ - Example: `'Testing Specialist'`
48
+
49
+ #### **tools** (OPTIONAL)
50
+
51
+ - List of tool names or aliases the agent can use
52
+ - Supports comma-separated string or YAML array format
53
+ - If omitted, agent has access to all available tools
54
+ - See "Tool Configuration" section below for details
55
+
56
+ #### **model** (STRONGLY RECOMMENDED)
57
+
58
+ - Specifies which AI model the agent should use
59
+ - Supported in VS Code, JetBrains IDEs, Eclipse, and Xcode
60
+ - Example: `'Claude Sonnet 4.5'`, `'gpt-4'`, `'gpt-4o'`
61
+ - Choose based on agent complexity and required capabilities
62
+
63
+ #### **target** (OPTIONAL)
64
+
65
+ - Specifies target environment: `'vscode'` or `'github-copilot'`
66
+ - If omitted, agent is available in both environments
67
+ - Use when agent has environment-specific features
68
+
69
+ #### **infer** (OPTIONAL)
70
+
71
+ - Boolean controlling whether Copilot can automatically use this agent based on context
72
+ - Default: `true` if omitted
73
+ - Set to `false` to require manual agent selection
74
+
75
+ #### **metadata** (OPTIONAL, GitHub.com only)
76
+
77
+ - Object with name-value pairs for agent annotation
78
+ - Example: `metadata: { category: 'testing', version: '1.0' }`
79
+ - Not supported in VS Code
80
+
81
+ #### **mcp-servers** (OPTIONAL, Organization/Enterprise only)
82
+
83
+ - Configure MCP servers available only to this agent
84
+ - Only supported for organization/enterprise level agents
85
+ - See "MCP Server Configuration" section below
86
+
87
+ #### **handoffs** (OPTIONAL, VS Code only)
88
+
89
+ - Enable guided sequential workflows that transition between agents with suggested next steps
90
+ - List of handoff configurations, each specifying a target agent and optional prompt
91
+ - After a chat response completes, handoff buttons appear allowing users to move to the next agent
92
+ - Only supported in VS Code (version 1.106+)
93
+ - See "Handoffs Configuration" section below for details
94
+
95
+ ## Handoffs Configuration
96
+
97
+ Handoffs enable you to create guided sequential workflows that transition seamlessly between custom agents. This is useful for orchestrating multi-step development workflows where users can review and approve each step before moving to the next one.
98
+
99
+ ### Common Handoff Patterns
100
+
101
+ - **Planning → Implementation**: Generate a plan in a planning agent, then hand off to an implementation agent to start coding
102
+ - **Implementation → Review**: Complete implementation, then switch to a code review agent to check for quality and security issues
103
+ - **Write Failing Tests → Write Passing Tests**: Generate failing tests, then hand off to implement the code that makes those tests pass
104
+ - **Research → Documentation**: Research a topic, then transition to a documentation agent to write guides
105
+
106
+ ### Handoff Frontmatter Structure
107
+
108
+ Define handoffs in the agent file's YAML frontmatter using the `handoffs` field:
109
+
110
+ ```yaml
111
+ ---
112
+ description: "Brief description of the agent"
113
+ name: "Agent Name"
114
+ tools: ["search", "read"]
115
+ handoffs:
116
+ - label: Start Implementation
117
+ agent: implementation
118
+ prompt: "Now implement the plan outlined above."
119
+ send: false
120
+ - label: Code Review
121
+ agent: code-review
122
+ prompt: "Please review the implementation for quality and security issues."
123
+ send: false
124
+ ---
125
+ ```
126
+
127
+ ### Handoff Properties
128
+
129
+ Each handoff in the list must include the following properties:
130
+
131
+ | Property | Type | Required | Description |
132
+ | -------- | ------- | -------- | ---------------------------------------------------------------------------------- |
133
+ | `label` | string | Yes | The display text shown on the handoff button in the chat interface |
134
+ | `agent` | string | Yes | The target agent identifier to switch to (name or filename without `.agent.md`) |
135
+ | `prompt` | string | No | The prompt text to pre-fill in the target agent's chat input |
136
+ | `send` | boolean | No | If `true`, automatically submits the prompt to the target agent (default: `false`) |
137
+
138
+ ### Handoff Behavior
139
+
140
+ - **Button Display**: Handoff buttons appear as interactive suggestions after a chat response completes
141
+ - **Context Preservation**: When users select a handoff button, they switch to the target agent with conversation context maintained
142
+ - **Pre-filled Prompt**: If a `prompt` is specified, it appears pre-filled in the target agent's chat input
143
+ - **Manual vs Auto**: When `send: false`, users must review and manually send the pre-filled prompt; when `send: true`, the prompt is automatically submitted
144
+
145
+ ### Handoff Configuration Guidelines
146
+
147
+ #### When to Use Handoffs
148
+
149
+ - **Multi-step workflows**: Breaking down complex tasks across specialized agents
150
+ - **Quality gates**: Ensuring review steps between implementation phases
151
+ - **Guided processes**: Directing users through a structured development process
152
+ - **Skill transitions**: Moving from planning/design to implementation/testing specialists
153
+
154
+ #### Best Practices
155
+
156
+ - **Clear Labels**: Use action-oriented labels that clearly indicate the next step
157
+ - ✅ Good: "Start Implementation", "Review for Security", "Write Tests"
158
+ - ❌ Avoid: "Next", "Go to agent", "Do something"
159
+
160
+ - **Relevant Prompts**: Provide context-aware prompts that reference the completed work
161
+ - ✅ Good: `'Now implement the plan outlined above.'`
162
+ - ❌ Avoid: Generic prompts without context
163
+
164
+ - **Selective Use**: Don't create handoffs to every possible agent; focus on logical workflow transitions
165
+ - Limit to 2-3 most relevant next steps per agent
166
+ - Only add handoffs for agents that naturally follow in the workflow
167
+
168
+ - **Agent Dependencies**: Ensure target agents exist before creating handoffs
169
+ - Handoffs to non-existent agents will be silently ignored
170
+ - Test handoffs to verify they work as expected
171
+
172
+ - **Prompt Content**: Keep prompts concise and actionable
173
+ - Refer to work from the current agent without duplicating content
174
+ - Provide any necessary context the target agent might need
175
+
176
+ ### Example: Complete Workflow
177
+
178
+ Here's an example of three agents with handoffs creating a complete workflow:
179
+
180
+ **Planning Agent** (`planner.agent.md`):
181
+
182
+ ```yaml
183
+ ---
184
+ description: 'Generate an implementation plan for new features or refactoring'
185
+ name: 'Planner'
186
+ tools: ['search', 'read']
187
+ handoffs:
188
+ - label: Implement Plan
189
+ agent: implementer
190
+ prompt: 'Implement the plan outlined above.'
191
+ send: false
192
+ ---
193
+ # Planner Agent
194
+ You are a planning specialist. Your task is to:
195
+ 1. Analyze the requirements
196
+ 2. Break down the work into logical steps
197
+ 3. Generate a detailed implementation plan
198
+ 4. Identify testing requirements
199
+
200
+ Do not write any code - focus only on planning.
201
+ ```
202
+
203
+ **Implementation Agent** (`implementer.agent.md`):
204
+
205
+ ```yaml
206
+ ---
207
+ description: 'Implement code based on a plan or specification'
208
+ name: 'Implementer'
209
+ tools: ['read', 'edit', 'search', 'execute']
210
+ handoffs:
211
+ - label: Review Implementation
212
+ agent: reviewer
213
+ prompt: 'Please review this implementation for code quality, security, and adherence to best practices.'
214
+ send: false
215
+ ---
216
+ # Implementer Agent
217
+ You are an implementation specialist. Your task is to:
218
+ 1. Follow the provided plan or specification
219
+ 2. Write clean, maintainable code
220
+ 3. Include appropriate comments and documentation
221
+ 4. Follow project coding standards
222
+
223
+ Implement the solution completely and thoroughly.
224
+ ```
225
+
226
+ **Review Agent** (`reviewer.agent.md`):
227
+
228
+ ```yaml
229
+ ---
230
+ description: 'Review code for quality, security, and best practices'
231
+ name: 'Reviewer'
232
+ tools: ['read', 'search']
233
+ handoffs:
234
+ - label: Back to Planning
235
+ agent: planner
236
+ prompt: 'Review the feedback above and determine if a new plan is needed.'
237
+ send: false
238
+ ---
239
+ # Code Review Agent
240
+ You are a code review specialist. Your task is to:
241
+ 1. Check code quality and maintainability
242
+ 2. Identify security issues and vulnerabilities
243
+ 3. Verify adherence to project standards
244
+ 4. Suggest improvements
245
+
246
+ Provide constructive feedback on the implementation.
247
+ ```
248
+
249
+ This workflow allows a developer to:
250
+
251
+ 1. Start with the Planner agent to create a detailed plan
252
+ 2. Hand off to the Implementer agent to write code based on the plan
253
+ 3. Hand off to the Reviewer agent to check the implementation
254
+ 4. Optionally hand off back to planning if significant issues are found
255
+
256
+ ### Version Compatibility
257
+
258
+ - **VS Code**: Handoffs are supported in VS Code 1.106 and later
259
+ - **GitHub.com**: Not currently supported; agent transition workflows use different mechanisms
260
+ - **Other IDEs**: Limited or no support; focus on VS Code implementations for maximum compatibility
261
+
262
+ ## Tool Configuration
263
+
264
+ ### Tool Specification Strategies
265
+
266
+ **Enable all tools** (default):
267
+
268
+ ```yaml
269
+ # Omit tools property entirely, or use:
270
+ tools: ["*"]
271
+ ```
272
+
273
+ **Enable specific tools**:
274
+
275
+ ```yaml
276
+ tools: ["read", "edit", "search", "execute"]
277
+ ```
278
+
279
+ **Enable MCP server tools**:
280
+
281
+ ```yaml
282
+ tools: ["read", "edit", "github/*", "playwright/navigate"]
283
+ ```
284
+
285
+ **Disable all tools**:
286
+
287
+ ```yaml
288
+ tools: []
289
+ ```
290
+
291
+ ### Standard Tool Aliases
292
+
293
+ All aliases are case-insensitive:
294
+
295
+ | Alias | Alternative Names | Category | Description |
296
+ | --------- | ------------------------------------ | ---------------- | ------------------------------------------- |
297
+ | `execute` | shell, Bash, powershell | Shell execution | Execute commands in appropriate shell |
298
+ | `read` | Read, NotebookRead, view | File reading | Read file contents |
299
+ | `edit` | Edit, MultiEdit, Write, NotebookEdit | File editing | Edit and modify files |
300
+ | `search` | Grep, Glob, search | Code search | Search for files or text in files |
301
+ | `agent` | custom-agent, Task | Agent invocation | Invoke other custom agents |
302
+ | `web` | WebSearch, WebFetch | Web access | Fetch web content and search |
303
+ | `todo` | TodoWrite | Task management | Create and manage task lists (VS Code only) |
304
+
305
+ ### Built-in MCP Server Tools
306
+
307
+ **GitHub MCP Server**:
308
+
309
+ ```yaml
310
+ tools: ['github/*'] # All GitHub tools
311
+ tools: ['github/get_file_contents', 'github/search_repositories'] # Specific tools
312
+ ```
313
+
314
+ - All read-only tools available by default
315
+ - Token scoped to source repository
316
+
317
+ **Playwright MCP Server**:
318
+
319
+ ```yaml
320
+ tools: ['playwright/*'] # All Playwright tools
321
+ tools: ['playwright/navigate', 'playwright/screenshot'] # Specific tools
322
+ ```
323
+
324
+ - Configured to access localhost only
325
+ - Useful for browser automation and testing
326
+
327
+ ### Tool Selection Best Practices
328
+
329
+ - **Principle of Least Privilege**: Only enable tools necessary for the agent's purpose
330
+ - **Security**: Limit `execute` access unless explicitly required
331
+ - **Focus**: Fewer tools = clearer agent purpose and better performance
332
+ - **Documentation**: Comment why specific tools are required for complex configurations
333
+
334
+ ## Sub-Agent Invocation (Agent Orchestration)
335
+
336
+ Agents can invoke other agents using the **agent invocation tool** (the `agent` tool) to orchestrate multi-step workflows.
337
+
338
+ The recommended approach is **prompt-based orchestration**:
339
+
340
+ - The orchestrator defines a step-by-step workflow in natural language.
341
+ - Each step is delegated to a specialized agent.
342
+ - The orchestrator passes only the essential context (e.g., base path, identifiers) and requires each sub-agent to read its own `.agent.md` spec for tools/constraints.
343
+
344
+ ### How It Works
345
+
346
+ 1. Enable agent invocation by including `agent` in the orchestrator's tools list:
347
+
348
+ ```yaml
349
+ tools: ["read", "edit", "search", "agent"]
350
+ ```
351
+
352
+ 2. For each step, invoke a sub-agent by providing:
353
+
354
+ - **Agent name** (the identifier users select/invoke)
355
+ - **Agent spec path** (the `.agent.md` file to read and follow)
356
+ - **Minimal shared context** (e.g., `basePath`, `projectName`, `logFile`)
357
+
358
+ ### Prompt Pattern (Recommended)
359
+
360
+ Use a consistent “wrapper prompt” for every step so sub-agents behave predictably:
361
+
362
+ ```text
363
+ This phase must be performed as the agent "<AGENT_NAME>" defined in "<AGENT_SPEC_PATH>".
364
+
365
+ IMPORTANT:
366
+ - Read and apply the entire .agent.md spec (tools, constraints, quality standards).
367
+ - Work on "<WORK_UNIT_NAME>" with base path: "<BASE_PATH>".
368
+ - Perform the necessary reads/writes under this base path.
369
+ - Return a clear summary (actions taken + files produced/modified + issues).
370
+ ```
371
+
372
+ Optional: if you need a lightweight, structured wrapper for traceability, embed a small JSON block in the prompt (still human-readable and tool-agnostic):
373
+
374
+ ```text
375
+ {
376
+ "step": "<STEP_ID>",
377
+ "agent": "<AGENT_NAME>",
378
+ "spec": "<AGENT_SPEC_PATH>",
379
+ "basePath": "<BASE_PATH>"
380
+ }
381
+ ```
382
+
383
+ ### Orchestrator Structure (Keep It Generic)
384
+
385
+ For maintainable orchestrators, document these structural elements:
386
+
387
+ - **Dynamic parameters**: what values are extracted from the user (e.g., `projectName`, `fileName`, `basePath`).
388
+ - **Sub-agent registry**: a list/table mapping each step to `agentName` + `agentSpecPath`.
389
+ - **Step ordering**: explicit sequence (Step 1 → Step N).
390
+ - **Trigger conditions** (optional but recommended): define when a step runs vs is skipped.
391
+ - **Logging strategy** (optional but recommended): a single log/report file updated after each step.
392
+
393
+ Avoid embedding orchestration “code” (JavaScript, Python, etc.) inside the orchestrator prompt; prefer deterministic, tool-driven coordination.
394
+
395
+ ### Basic Pattern
396
+
397
+ Structure each step invocation with:
398
+
399
+ 1. **Step description**: Clear one-line purpose (used for logs and traceability)
400
+ 2. **Agent identity**: `agentName` + `agentSpecPath`
401
+ 3. **Context**: A small, explicit set of variables (paths, IDs, environment name)
402
+ 4. **Expected outputs**: Files to create/update and where they should be written
403
+ 5. **Return summary**: Ask the sub-agent to return a short, structured summary
404
+
405
+ ### Example: Multi-Step Processing
406
+
407
+ ```text
408
+ Step 1: Transform raw input data
409
+ Agent: data-processor
410
+ Spec: .github/agents/data-processor.agent.md
411
+ Context: projectName=${projectName}, basePath=${basePath}
412
+ Input: ${basePath}/raw/
413
+ Output: ${basePath}/processed/
414
+ Expected: write ${basePath}/processed/summary.md
415
+
416
+ Step 2: Analyze processed data (depends on Step 1 output)
417
+ Agent: data-analyst
418
+ Spec: .github/agents/data-analyst.agent.md
419
+ Context: projectName=${projectName}, basePath=${basePath}
420
+ Input: ${basePath}/processed/
421
+ Output: ${basePath}/analysis/
422
+ Expected: write ${basePath}/analysis/report.md
423
+ ```
424
+
425
+ ### Key Points
426
+
427
+ - **Pass variables in prompts**: Use `${variableName}` for all dynamic values
428
+ - **Keep prompts focused**: Clear, specific tasks for each sub-agent
429
+ - **Return summaries**: Each sub-agent should report what it accomplished
430
+ - **Sequential execution**: Run steps in order when dependencies exist between outputs/inputs
431
+ - **Error handling**: Check results before proceeding to dependent steps
432
+
433
+ ### ⚠️ Tool Availability Requirement
434
+
435
+ **Critical**: If a sub-agent requires specific tools (e.g., `edit`, `execute`, `search`), the orchestrator must include those tools in its own `tools` list. Sub-agents cannot access tools that aren't available to their parent orchestrator.
436
+
437
+ **Example**:
438
+
439
+ ```yaml
440
+ # If your sub-agents need to edit files, execute commands, or search code
441
+ tools: ["read", "edit", "search", "execute", "agent"]
442
+ ```
443
+
444
+ The orchestrator's tool permissions act as a ceiling for all invoked sub-agents. Plan your tool list carefully to ensure all sub-agents have the tools they need.
445
+
446
+ ### ⚠️ Important Limitation
447
+
448
+ **Sub-agent orchestration is NOT suitable for large-scale data processing.** Avoid using multi-step sub-agent pipelines when:
449
+
450
+ - Processing hundreds or thousands of files
451
+ - Handling large datasets
452
+ - Performing bulk transformations on big codebases
453
+ - Orchestrating more than 5-10 sequential steps
454
+
455
+ Each sub-agent invocation adds latency and context overhead. For high-volume processing, implement logic directly in a single agent instead. Use orchestration only for coordinating specialized tasks on focused, manageable datasets.
456
+
457
+ ## Agent Prompt Structure
458
+
459
+ The markdown content below the frontmatter defines the agent's behavior, expertise, and instructions. Well-structured prompts typically include:
460
+
461
+ 1. **Agent Identity and Role**: Who the agent is and its primary role
462
+ 2. **Core Responsibilities**: What specific tasks the agent performs
463
+ 3. **Approach and Methodology**: How the agent works to accomplish tasks
464
+ 4. **Guidelines and Constraints**: What to do/avoid and quality standards
465
+ 5. **Output Expectations**: Expected output format and quality
466
+
467
+ ### Prompt Writing Best Practices
468
+
469
+ - **Be Specific and Direct**: Use imperative mood ("Analyze", "Generate"); avoid vague terms
470
+ - **Define Boundaries**: Clearly state scope limits and constraints
471
+ - **Include Context**: Explain domain expertise and reference relevant frameworks
472
+ - **Focus on Behavior**: Describe how the agent should think and work
473
+ - **Use Structured Format**: Headers, bullets, and lists make prompts scannable
474
+
475
+ ## Variable Definition and Extraction
476
+
477
+ Agents can define dynamic parameters to extract values from user input and use them throughout the agent's behavior and sub-agent communications. This enables flexible, context-aware agents that adapt to user-provided data.
478
+
479
+ ### When to Use Variables
480
+
481
+ **Use variables when**:
482
+
483
+ - Agent behavior depends on user input
484
+ - Need to pass dynamic values to sub-agents
485
+ - Want to make agents reusable across different contexts
486
+ - Require parameterized workflows
487
+ - Need to track or reference user-provided context
488
+
489
+ **Examples**:
490
+
491
+ - Extract project name from user prompt
492
+ - Capture certification name for pipeline processing
493
+ - Identify file paths or directories
494
+ - Extract configuration options
495
+ - Parse feature names or module identifiers
496
+
497
+ ### Variable Declaration Pattern
498
+
499
+ Define variables section early in the agent prompt to document expected parameters:
500
+
501
+ ```markdown
502
+ # Agent Name
503
+
504
+ ## Dynamic Parameters
505
+
506
+ - **Parameter Name**: Description and usage
507
+ - **Another Parameter**: How it's extracted and used
508
+
509
+ ## Your Mission
510
+
511
+ Process [PARAMETER_NAME] to accomplish [task].
512
+ ```
513
+
514
+ ### Variable Extraction Methods
515
+
516
+ #### 1. **Explicit User Input**
517
+
518
+ Ask the user to provide the variable if not detected in the prompt:
519
+
520
+ ```markdown
521
+ ## Your Mission
522
+
523
+ Process the project by analyzing your codebase.
524
+
525
+ ### Step 1: Identify Project
526
+
527
+ If no project name is provided, **ASK THE USER** for:
528
+
529
+ - Project name or identifier
530
+ - Base path or directory location
531
+ - Configuration type (if applicable)
532
+
533
+ Use this information to contextualize all subsequent tasks.
534
+ ```
535
+
536
+ #### 2. **Implicit Extraction from Prompt**
537
+
538
+ Automatically extract variables from the user's natural language input:
539
+
540
+ ```javascript
541
+ // Example: Extract certification name from user input
542
+ const userInput = "Process My Certification";
543
+
544
+ // Extract key information
545
+ const certificationName = extractCertificationName(userInput);
546
+ // Result: "My Certification"
547
+
548
+ const basePath = `certifications/${certificationName}`;
549
+ // Result: "certifications/My Certification"
550
+ ```
551
+
552
+ #### 3. **Contextual Variable Resolution**
553
+
554
+ Use file context or workspace information to derive variables:
555
+
556
+ ```markdown
557
+ ## Variable Resolution Strategy
558
+
559
+ 1. **From User Prompt**: First, look for explicit mentions in user input
560
+ 2. **From File Context**: Check current file name or path
561
+ 3. **From Workspace**: Use workspace folder or active project
562
+ 4. **From Settings**: Reference configuration files
563
+ 5. **Ask User**: If all else fails, request missing information
564
+ ```
565
+
566
+ ### Using Variables in Agent Prompts
567
+
568
+ #### Variable Substitution in Instructions
569
+
570
+ Use template variables in agent prompts to make them dynamic:
571
+
572
+ ```markdown
573
+ # Agent Name
574
+
575
+ ## Dynamic Parameters
576
+
577
+ - **Project Name**: ${projectName}
578
+ - **Base Path**: ${basePath}
579
+ - **Output Directory**: ${outputDir}
580
+
581
+ ## Your Mission
582
+
583
+ Process the **${projectName}** project located at `${basePath}`.
584
+
585
+ ## Process Steps
586
+
587
+ 1. Read input from: `${basePath}/input/`
588
+ 2. Process files according to project configuration
589
+ 3. Write results to: `${outputDir}/`
590
+ 4. Generate summary report
591
+
592
+ ## Quality Standards
593
+
594
+ - Maintain project-specific coding standards for **${projectName}**
595
+ - Follow directory structure: `${basePath}/[structure]`
596
+ ```
597
+
598
+ #### Passing Variables to Sub-Agents
599
+
600
+ When invoking a sub-agent, pass all context through substituted variables in the prompt. Prefer passing **paths and identifiers**, not entire file contents.
601
+
602
+ Example (prompt template):
603
+
604
+ ```text
605
+ This phase must be performed as the agent "documentation-writer" defined in ".github/agents/documentation-writer.agent.md".
606
+
607
+ IMPORTANT:
608
+ - Read and apply the entire .agent.md spec.
609
+ - Project: "${projectName}"
610
+ - Base path: "projects/${projectName}"
611
+ - Input: "projects/${projectName}/src/"
612
+ - Output: "projects/${projectName}/docs/"
613
+
614
+ Task:
615
+ 1. Read source files under the input path.
616
+ 2. Generate documentation.
617
+ 3. Write outputs under the output path.
618
+ 4. Return a concise summary (files created/updated, key decisions, issues).
619
+ ```
620
+
621
+ The sub-agent receives all necessary context embedded in the prompt. Variables are resolved before sending the prompt, so the sub-agent works with concrete paths and values, not variable placeholders.
622
+
623
+ ### Real-World Example: Code Review Orchestrator
624
+
625
+ Example of a simple orchestrator that validates code through multiple specialized agents:
626
+
627
+ 1. Determine shared context:
628
+
629
+ - `repositoryName`, `prNumber`
630
+ - `basePath` (e.g., `projects/${repositoryName}/pr-${prNumber}`)
631
+
632
+ 2. Invoke specialized agents sequentially (each agent reads its own `.agent.md` spec):
633
+
634
+ ```text
635
+ Step 1: Security Review
636
+ Agent: security-reviewer
637
+ Spec: .github/agents/security-reviewer.agent.md
638
+ Context: repositoryName=${repositoryName}, prNumber=${prNumber}, basePath=projects/${repositoryName}/pr-${prNumber}
639
+ Output: projects/${repositoryName}/pr-${prNumber}/security-review.md
640
+
641
+ Step 2: Test Coverage
642
+ Agent: test-coverage
643
+ Spec: .github/agents/test-coverage.agent.md
644
+ Context: repositoryName=${repositoryName}, prNumber=${prNumber}, basePath=projects/${repositoryName}/pr-${prNumber}
645
+ Output: projects/${repositoryName}/pr-${prNumber}/coverage-report.md
646
+
647
+ Step 3: Aggregate
648
+ Agent: review-aggregator
649
+ Spec: .github/agents/review-aggregator.agent.md
650
+ Context: repositoryName=${repositoryName}, prNumber=${prNumber}, basePath=projects/${repositoryName}/pr-${prNumber}
651
+ Output: projects/${repositoryName}/pr-${prNumber}/final-review.md
652
+ ```
653
+
654
+ #### Example: Conditional Step Orchestration (Code Review)
655
+
656
+ This example shows a more complete orchestration with **pre-flight checks**, **conditional steps**, and **required vs optional** behavior.
657
+
658
+ **Dynamic parameters (inputs):**
659
+
660
+ - `repositoryName`, `prNumber`
661
+ - `basePath` (e.g., `projects/${repositoryName}/pr-${prNumber}`)
662
+ - `logFile` (e.g., `${basePath}/.review-log.md`)
663
+
664
+ **Pre-flight checks (recommended):**
665
+
666
+ - Verify expected folders/files exist (e.g., `${basePath}/changes/`, `${basePath}/reports/`).
667
+ - Detect high-level characteristics that influence step triggers (e.g., repo language, presence of `package.json`, `pom.xml`, `requirements.txt`, test folders).
668
+ - Log the findings once at the start.
669
+
670
+ **Step trigger conditions:**
671
+
672
+ | Step | Status | Trigger Condition | On Failure |
673
+ | ---------------------- | ------------ | ----------------------------------------------------------------- | ------------- |
674
+ | 1: Security Review | **Required** | Always run | Stop pipeline |
675
+ | 2: Dependency Audit | Optional | If a dependency manifest exists (`package.json`, `pom.xml`, etc.) | Continue |
676
+ | 3: Test Coverage Check | Optional | If test projects/files are present | Continue |
677
+ | 4: Performance Checks | Optional | If perf-sensitive code changed OR a perf config exists | Continue |
678
+ | 5: Aggregate & Verdict | **Required** | Always run if Step 1 completed | Stop pipeline |
679
+
680
+ **Execution flow (natural language):**
681
+
682
+ 1. Initialize `basePath` and create/update `logFile`.
683
+ 2. Run pre-flight checks and record them.
684
+ 3. Execute Step 1 → N sequentially.
685
+ 4. For each step:
686
+
687
+ - If trigger condition is false: mark as **SKIPPED** and continue.
688
+ - Otherwise: invoke the sub-agent using the wrapper prompt and capture its summary.
689
+ - Mark as **SUCCESS** or **FAILED**.
690
+ - If the step is **Required** and failed: stop the pipeline and write a failure summary.
691
+
692
+ 5. End with a final summary section (overall status, artifacts, next actions).
693
+
694
+ **Sub-agent invocation prompt (example):**
695
+
696
+ ```text
697
+ This phase must be performed as the agent "security-reviewer" defined in ".github/agents/security-reviewer.agent.md".
698
+
699
+ IMPORTANT:
700
+ - Read and apply the entire .agent.md spec.
701
+ - Work on repository "${repositoryName}" PR "${prNumber}".
702
+ - Base path: "${basePath}".
703
+
704
+ Task:
705
+ 1. Review the changes under "${basePath}/changes/".
706
+ 2. Write findings to "${basePath}/reports/security-review.md".
707
+ 3. Return a short summary with: critical findings, recommended fixes, files created/modified.
708
+ ```
709
+
710
+ **Logging format (example):**
711
+
712
+ ```markdown
713
+ ## Step 2: Dependency Audit
714
+
715
+ **Status:** ✅ SUCCESS / ⚠️ SKIPPED / ❌ FAILED
716
+ **Trigger:** package.json present
717
+ **Started:** 2026-01-16T10:30:15Z
718
+ **Completed:** 2026-01-16T10:31:05Z
719
+ **Duration:** 00:00:50
720
+ **Artifacts:** reports/dependency-audit.md
721
+ **Summary:** [brief agent summary]
722
+ ```
723
+
724
+ This pattern applies to any orchestration scenario: extract variables, call sub-agents with clear context, await results.
725
+
726
+ ### Variable Best Practices
727
+
728
+ #### 1. **Clear Documentation**
729
+
730
+ Always document what variables are expected:
731
+
732
+ ```markdown
733
+ ## Required Variables
734
+
735
+ - **projectName**: The name of the project (string, required)
736
+ - **basePath**: Root directory for project files (path, required)
737
+
738
+ ## Optional Variables
739
+
740
+ - **mode**: Processing mode - quick/standard/detailed (enum, default: standard)
741
+ - **outputFormat**: Output format - markdown/json/html (enum, default: markdown)
742
+
743
+ ## Derived Variables
744
+
745
+ - **outputDir**: Automatically set to ${basePath}/output
746
+ - **logFile**: Automatically set to ${basePath}/.log.md
747
+ ```
748
+
749
+ #### 2. **Consistent Naming**
750
+
751
+ Use consistent variable naming conventions:
752
+
753
+ ```javascript
754
+ // Good: Clear, descriptive naming
755
+ const variables = {
756
+ projectName, // What project to work on
757
+ basePath, // Where project files are located
758
+ outputDirectory, // Where to save results
759
+ processingMode, // How to process (detail level)
760
+ configurationPath, // Where config files are
761
+ };
762
+
763
+ // Avoid: Ambiguous or inconsistent
764
+ const bad_variables = {
765
+ name, // Too generic
766
+ path, // Unclear which path
767
+ mode, // Too short
768
+ config, // Too vague
769
+ };
770
+ ```
771
+
772
+ #### 3. **Validation and Constraints**
773
+
774
+ Document valid values and constraints:
775
+
776
+ ```markdown
777
+ ## Variable Constraints
778
+
779
+ **projectName**:
780
+
781
+ - Type: string (alphanumeric, hyphens, underscores allowed)
782
+ - Length: 1-100 characters
783
+ - Required: yes
784
+ - Pattern: `/^[a-zA-Z0-9_-]+$/`
785
+
786
+ **processingMode**:
787
+
788
+ - Type: enum
789
+ - Valid values: "quick" (< 5min), "standard" (5-15min), "detailed" (15+ min)
790
+ - Default: "standard"
791
+ - Required: no
792
+ ```
793
+
794
+ ## MCP Server Configuration (Organization/Enterprise Only)
795
+
796
+ MCP servers extend agent capabilities with additional tools. Only supported for organization and enterprise-level agents.
797
+
798
+ ### Configuration Format
799
+
800
+ ```yaml
801
+ ---
802
+ name: my-custom-agent
803
+ description: "Agent with MCP integration"
804
+ tools: ["read", "edit", "custom-mcp/tool-1"]
805
+ mcp-servers:
806
+ custom-mcp:
807
+ type: "local"
808
+ command: "some-command"
809
+ args: ["--arg1", "--arg2"]
810
+ tools: ["*"]
811
+ env:
812
+ ENV_VAR_NAME: ${{ secrets.API_KEY }}
813
+ ---
814
+ ```
815
+
816
+ ### MCP Server Properties
817
+
818
+ - **type**: Server type (`'local'` or `'stdio'`)
819
+ - **command**: Command to start the MCP server
820
+ - **args**: Array of command arguments
821
+ - **tools**: Tools to enable from this server (`["*"]` for all)
822
+ - **env**: Environment variables (supports secrets)
823
+
824
+ ### Environment Variables and Secrets
825
+
826
+ Secrets must be configured in repository settings under "copilot" environment.
827
+
828
+ **Supported syntax**:
829
+
830
+ ```yaml
831
+ env:
832
+ # Environment variable only
833
+ VAR_NAME: COPILOT_MCP_ENV_VAR_VALUE
834
+
835
+ # Variable with header
836
+ VAR_NAME: $COPILOT_MCP_ENV_VAR_VALUE
837
+ VAR_NAME: ${COPILOT_MCP_ENV_VAR_VALUE}
838
+
839
+ # GitHub Actions-style (YAML only)
840
+ VAR_NAME: ${{ secrets.COPILOT_MCP_ENV_VAR_VALUE }}
841
+ VAR_NAME: ${{ var.COPILOT_MCP_ENV_VAR_VALUE }}
842
+ ```
843
+
844
+ ## File Organization and Naming
845
+
846
+ ### Repository-Level Agents
847
+
848
+ - Location: `.github/agents/`
849
+ - Scope: Available only in the specific repository
850
+ - Access: Uses repository-configured MCP servers
851
+
852
+ ### Organization/Enterprise-Level Agents
853
+
854
+ - Location: `.github-private/agents/` (then move to `agents/` root)
855
+ - Scope: Available across all repositories in org/enterprise
856
+ - Access: Can configure dedicated MCP servers
857
+
858
+ ### Naming Conventions
859
+
860
+ - Use lowercase with hyphens: `test-specialist.agent.md`
861
+ - Name should reflect agent purpose
862
+ - Filename becomes default agent name (if `name` not specified)
863
+ - Allowed characters: `.`, `-`, `_`, `a-z`, `A-Z`, `0-9`
864
+
865
+ ## Agent Processing and Behavior
866
+
867
+ ### Versioning
868
+
869
+ - Based on Git commit SHAs for the agent file
870
+ - Create branches/tags for different agent versions
871
+ - Instantiated using latest version for repository/branch
872
+ - PR interactions use same agent version for consistency
873
+
874
+ ### Name Conflicts
875
+
876
+ Priority (highest to lowest):
877
+
878
+ 1. Repository-level agent
879
+ 2. Organization-level agent
880
+ 3. Enterprise-level agent
881
+
882
+ Lower-level configurations override higher-level ones with the same name.
883
+
884
+ ### Tool Processing
885
+
886
+ - `tools` list filters available tools (built-in and MCP)
887
+ - No tools specified = all tools enabled
888
+ - Empty list (`[]`) = all tools disabled
889
+ - Specific list = only those tools enabled
890
+ - Unrecognized tool names are ignored (allows environment-specific tools)
891
+
892
+ ### MCP Server Processing Order
893
+
894
+ 1. Out-of-the-box MCP servers (e.g., GitHub MCP)
895
+ 2. Custom agent MCP configuration (org/enterprise only)
896
+ 3. Repository-level MCP configurations
897
+
898
+ Each level can override settings from previous levels.
899
+
900
+ ## Agent Creation Checklist
901
+
902
+ ### Frontmatter
903
+
904
+ - [ ] `description` field present and descriptive (50-150 chars)
905
+ - [ ] `description` wrapped in single quotes
906
+ - [ ] `name` specified (optional but recommended)
907
+ - [ ] `tools` configured appropriately (or intentionally omitted)
908
+ - [ ] `model` specified for optimal performance
909
+ - [ ] `target` set if environment-specific
910
+ - [ ] `infer` set to `false` if manual selection required
911
+
912
+ ### Prompt Content
913
+
914
+ - [ ] Clear agent identity and role defined
915
+ - [ ] Core responsibilities listed explicitly
916
+ - [ ] Approach and methodology explained
917
+ - [ ] Guidelines and constraints specified
918
+ - [ ] Output expectations documented
919
+ - [ ] Examples provided where helpful
920
+ - [ ] Instructions are specific and actionable
921
+ - [ ] Scope and boundaries clearly defined
922
+ - [ ] Total content under 30,000 characters
923
+
924
+ ### File Structure
925
+
926
+ - [ ] Filename follows lowercase-with-hyphens convention
927
+ - [ ] File placed in correct directory (`.github/agents/` or `agents/`)
928
+ - [ ] Filename uses only allowed characters
929
+ - [ ] File extension is `.agent.md`
930
+
931
+ ### Quality Assurance
932
+
933
+ - [ ] Agent purpose is unique and not duplicative
934
+ - [ ] Tools are minimal and necessary
935
+ - [ ] Instructions are clear and unambiguous
936
+ - [ ] Agent has been tested with representative tasks
937
+ - [ ] Documentation references are current
938
+ - [ ] Security considerations addressed (if applicable)
939
+
940
+ ## Common Agent Patterns
941
+
942
+ ### Testing Specialist
943
+
944
+ **Purpose**: Focus on test coverage and quality
945
+ **Tools**: All tools (for comprehensive test creation)
946
+ **Approach**: Analyze, identify gaps, write tests, avoid production code changes
947
+
948
+ ### Implementation Planner
949
+
950
+ **Purpose**: Create detailed technical plans and specifications
951
+ **Tools**: Limited to `['read', 'search', 'edit']`
952
+ **Approach**: Analyze requirements, create documentation, avoid implementation
953
+
954
+ ### Code Reviewer
955
+
956
+ **Purpose**: Review code quality and provide feedback
957
+ **Tools**: `['read', 'search']` only
958
+ **Approach**: Analyze, suggest improvements, no direct modifications
959
+
960
+ ### Refactoring Specialist
961
+
962
+ **Purpose**: Improve code structure and maintainability
963
+ **Tools**: `['read', 'search', 'edit']`
964
+ **Approach**: Analyze patterns, propose refactorings, implement safely
965
+
966
+ ### Security Auditor
967
+
968
+ **Purpose**: Identify security issues and vulnerabilities
969
+ **Tools**: `['read', 'search', 'web']`
970
+ **Approach**: Scan code, check against OWASP, report findings
971
+
972
+ ## Common Mistakes to Avoid
973
+
974
+ ### Frontmatter Errors
975
+
976
+ - ❌ Missing `description` field
977
+ - ❌ Description not wrapped in quotes
978
+ - ❌ Invalid tool names without checking documentation
979
+ - ❌ Incorrect YAML syntax (indentation, quotes)
980
+
981
+ ### Tool Configuration Issues
982
+
983
+ - ❌ Granting excessive tool access unnecessarily
984
+ - ❌ Missing required tools for agent's purpose
985
+ - ❌ Not using tool aliases consistently
986
+ - ❌ Forgetting MCP server namespace (`server-name/tool`)
987
+
988
+ ### Prompt Content Problems
989
+
990
+ - ❌ Vague, ambiguous instructions
991
+ - ❌ Conflicting or contradictory guidelines
992
+ - ❌ Lack of clear scope definition
993
+ - ❌ Missing output expectations
994
+ - ❌ Overly verbose instructions (exceeding character limits)
995
+ - ❌ No examples or context for complex tasks
996
+
997
+ ### Organizational Issues
998
+
999
+ - ❌ Filename doesn't reflect agent purpose
1000
+ - ❌ Wrong directory (confusing repo vs org level)
1001
+ - ❌ Using spaces or special characters in filename
1002
+ - ❌ Duplicate agent names causing conflicts
1003
+
1004
+ ## Testing and Validation
1005
+
1006
+ ### Manual Testing
1007
+
1008
+ 1. Create the agent file with proper frontmatter
1009
+ 2. Reload VS Code or refresh GitHub.com
1010
+ 3. Select the agent from the dropdown in Copilot Chat
1011
+ 4. Test with representative user queries
1012
+ 5. Verify tool access works as expected
1013
+ 6. Confirm output meets expectations
1014
+
1015
+ ### Integration Testing
1016
+
1017
+ - Test agent with different file types in scope
1018
+ - Verify MCP server connectivity (if configured)
1019
+ - Check agent behavior with missing context
1020
+ - Test error handling and edge cases
1021
+ - Validate agent switching and handoffs
1022
+
1023
+ ### Quality Checks
1024
+
1025
+ - Run through agent creation checklist
1026
+ - Review against common mistakes list
1027
+ - Compare with example agents in repository
1028
+ - Get peer review for complex agents
1029
+ - Document any special configuration needs
1030
+
1031
+ ## Additional Resources
1032
+
1033
+ ### Official Documentation
1034
+
1035
+ - [Creating Custom Agents](https://docs.github.com/en/copilot/how-tos/use-copilot-agents/coding-agent/create-custom-agents)
1036
+ - [Custom Agents Configuration](https://docs.github.com/en/copilot/reference/custom-agents-configuration)
1037
+ - [Custom Agents in VS Code](https://code.visualstudio.com/docs/copilot/customization/custom-agents)
1038
+ - [MCP Integration](https://docs.github.com/en/copilot/how-tos/use-copilot-agents/coding-agent/extend-coding-agent-with-mcp)
1039
+
1040
+ ### Community Resources
1041
+
1042
+ - [Awesome Copilot Agents Collection](https://github.com/github/awesome-copilot/tree/main/agents)
1043
+ - [Customization Library Examples](https://docs.github.com/en/copilot/tutorials/customization-library/custom-agents)
1044
+ - [Your First Custom Agent Tutorial](https://docs.github.com/en/copilot/tutorials/customization-library/custom-agents/your-first-custom-agent)
1045
+
1046
+ ### Related Files
1047
+
1048
+ - [Prompt Files Guidelines](./prompt.instructions.md) - For creating prompt files
1049
+ - [Instructions Guidelines](./instructions.instructions.md) - For creating instruction files
1050
+
1051
+ ## Version Compatibility Notes
1052
+
1053
+ ### GitHub.com (Coding Agent)
1054
+
1055
+ - ✅ Fully supports all standard frontmatter properties
1056
+ - ✅ Repository and org/enterprise level agents
1057
+ - ✅ MCP server configuration (org/enterprise)
1058
+ - ❌ Does not support `model`, `argument-hint`, `handoffs` properties
1059
+
1060
+ ### VS Code / JetBrains / Eclipse / Xcode
1061
+
1062
+ - ✅ Supports `model` property for AI model selection
1063
+ - ✅ Supports `argument-hint` and `handoffs` properties
1064
+ - ✅ User profile and workspace-level agents
1065
+ - ❌ Cannot configure MCP servers at repository level
1066
+ - ⚠️ Some properties may behave differently
1067
+
1068
+ When creating agents for multiple environments, focus on common properties and test in all target environments. Use `target` property to create environment-specific agents when necessary.