Skip to content

Commit 4e7efbe

Browse files
committed
Add three .github prompts for API, code, tests
Add three prompt templates under .github/prompts: document-api.prompt.md, explain-code.prompt.md, and generate-unit-tests.prompt.md. Each file provides an agent prompt and guidance for automated content generation: document-api guides generation of OpenAPI 3.0.3 YAML specs (paths, components, schemas, security, examples); explain-code produces beginner-friendly code explanations with breakdowns and examples; generate-unit-tests outlines strategies and templates for creating 5–8 focused unit tests following AAA and project test framework conventions. Includes input placeholders to target specific endpoints, code snippets, or functions.
1 parent b6bf675 commit 4e7efbe

3 files changed

Lines changed: 123 additions & 0 deletions

File tree

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
---
2+
agent: 'agent'
3+
description: 'Generate OpenAPI 3.0 specification for API endpoints'
4+
---
5+
6+
## Task
7+
8+
Analyze the API endpoint code and generate a valid OpenAPI 3.0 specification in YAML format.
9+
10+
## OpenAPI Structure
11+
12+
Generate a complete OpenAPI spec including:
13+
14+
1. **OpenAPI Header**
15+
- OpenAPI version (3.0.3)
16+
- API info (title, description, version)
17+
- Server configuration
18+
19+
2. **Path Definitions**
20+
- HTTP method and path
21+
- Operation summary and description
22+
- Tags for organization
23+
24+
3. **Parameters Schema**
25+
- Path parameters with type validation
26+
- Query parameters with constraints and defaults
27+
- Request body schema using proper JSON Schema
28+
- Required vs optional parameters
29+
30+
4. **Response Schemas**
31+
- Success responses (200, 201, etc.) with schema definitions
32+
- Error responses (400, 401, 404, 500) with error schema
33+
- Content-Type specifications
34+
- Realistic example values
35+
36+
5. **Components Section**
37+
- Reusable schemas for request/response models
38+
- Security schemes (Bearer token, API key, etc.)
39+
- Common parameter definitions
40+
41+
## Requirements
42+
43+
- Generate valid OpenAPI 3.0.3 YAML that passes validation
44+
- Use proper JSON Schema for all data models
45+
- Include realistic example values, not placeholders
46+
- Define reusable components to avoid duplication
47+
- Add appropriate data validation (required fields, formats, constraints)
48+
- Include security requirements where applicable
49+
50+
Focus on: ${input:endpoint_focus:Which specific endpoint or endpoints should be documented?}
51+
52+
Generate production-ready OpenAPI specification that can be used with Swagger UI, Postman, and code generators.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
agent: 'agent'
3+
description: 'Generate a clear code explanation with examples'
4+
---
5+
6+
Explain the following code in a clear, beginner-friendly way:
7+
8+
Code to explain: ${input:code:Paste your code here}
9+
Target audience: ${input:audience:Who is this explanation for? (e.g., beginners, intermediate developers, etc.)}
10+
11+
Please provide:
12+
13+
* A brief overview of what the code does
14+
* A step-by-step breakdown of the main parts
15+
* Explanation of any key concepts or terminology
16+
* A simple example showing how it works
17+
* Common use cases or when you might use this approach
18+
19+
Use clear, simple language and avoid unnecessary jargon.
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
---
2+
agent: 'agent'
3+
description: 'Generate unit tests for selected functions or methods'
4+
---
5+
6+
## Task
7+
8+
Analyze the selected function/method and generate focused unit tests that thoroughly validate its behavior.
9+
10+
## Test Generation Strategy
11+
12+
1. **Core Functionality Tests**
13+
- Test the main purpose/expected behavior
14+
- Verify return values with typical inputs
15+
- Test with realistic data scenarios
16+
17+
2. **Input Validation Tests**
18+
- Test with invalid input types
19+
- Test with null/undefined values
20+
- Test with empty strings/arrays/objects
21+
- Test boundary values (min/max, zero, negative numbers)
22+
23+
3. **Error Handling Tests**
24+
- Test expected exceptions are thrown
25+
- Verify error messages are meaningful
26+
- Test graceful handling of edge cases
27+
28+
4. **Side Effects Tests** (if applicable)
29+
- Verify external calls are made correctly
30+
- Test state changes
31+
- Validate interactions with dependencies
32+
33+
## Test Structure Requirements
34+
35+
- Use existing project testing framework and patterns
36+
- Follow AAA pattern: Arrange, Act, Assert
37+
- Write descriptive test names that explain the scenario
38+
- Group related tests in describe/context blocks
39+
- Mock external dependencies cleanly
40+
41+
Target function: ${input:function_name:Which function or method should be tested?}
42+
Testing framework: ${input:framework:Which framework? (jest/vitest/mocha/pytest/rspec/etc)}
43+
44+
## Guidelines
45+
46+
- Generate 5-8 focused test cases covering the most important scenarios
47+
- Include realistic test data, not just simple examples
48+
- Add comments for complex test setup or assertions
49+
- Ensure tests are independent and can run in any order
50+
- Focus on testing behavior, not implementation details
51+
52+
Create tests that give confidence the function works correctly and help catch regressions.

0 commit comments

Comments
 (0)