developer-ai 1.0.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.
- package/README.md +241 -0
- package/bin/developer-ai.js +2 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +219 -0
- package/dist/cli.js.map +1 -0
- package/dist/config/index.d.ts +7 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +82 -0
- package/dist/config/index.js.map +1 -0
- package/dist/config/schema.d.ts +115 -0
- package/dist/config/schema.d.ts.map +1 -0
- package/dist/config/schema.js +29 -0
- package/dist/config/schema.js.map +1 -0
- package/dist/constants.d.ts +8 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +8 -0
- package/dist/constants.js.map +1 -0
- package/dist/core/agent.d.ts +38 -0
- package/dist/core/agent.d.ts.map +1 -0
- package/dist/core/agent.js +155 -0
- package/dist/core/agent.js.map +1 -0
- package/dist/core/system-prompt.d.ts +6 -0
- package/dist/core/system-prompt.d.ts.map +1 -0
- package/dist/core/system-prompt.js +44 -0
- package/dist/core/system-prompt.js.map +1 -0
- package/dist/core/types.d.ts +42 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/core/types.js +6 -0
- package/dist/core/types.js.map +1 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp/client.d.ts +13 -0
- package/dist/mcp/client.d.ts.map +1 -0
- package/dist/mcp/client.js +202 -0
- package/dist/mcp/client.js.map +1 -0
- package/dist/providers/ollama.d.ts +13 -0
- package/dist/providers/ollama.d.ts.map +1 -0
- package/dist/providers/ollama.js +60 -0
- package/dist/providers/ollama.js.map +1 -0
- package/dist/providers/openai.d.ts +9 -0
- package/dist/providers/openai.d.ts.map +1 -0
- package/dist/providers/openai.js +40 -0
- package/dist/providers/openai.js.map +1 -0
- package/dist/skills/loader.d.ts +25 -0
- package/dist/skills/loader.d.ts.map +1 -0
- package/dist/skills/loader.js +93 -0
- package/dist/skills/loader.js.map +1 -0
- package/dist/tests/tools.test.d.ts +2 -0
- package/dist/tests/tools.test.d.ts.map +1 -0
- package/dist/tests/tools.test.js +170 -0
- package/dist/tests/tools.test.js.map +1 -0
- package/dist/tools/index.d.ts +5 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +19 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/list-files.d.ts +3 -0
- package/dist/tools/list-files.d.ts.map +1 -0
- package/dist/tools/list-files.js +60 -0
- package/dist/tools/list-files.js.map +1 -0
- package/dist/tools/read-file.d.ts +3 -0
- package/dist/tools/read-file.d.ts.map +1 -0
- package/dist/tools/read-file.js +46 -0
- package/dist/tools/read-file.js.map +1 -0
- package/dist/tools/registry.d.ts +24 -0
- package/dist/tools/registry.d.ts.map +1 -0
- package/dist/tools/registry.js +37 -0
- package/dist/tools/registry.js.map +1 -0
- package/dist/tools/run-command.d.ts +3 -0
- package/dist/tools/run-command.d.ts.map +1 -0
- package/dist/tools/run-command.js +114 -0
- package/dist/tools/run-command.js.map +1 -0
- package/dist/tools/search-text.d.ts +3 -0
- package/dist/tools/search-text.d.ts.map +1 -0
- package/dist/tools/search-text.js +103 -0
- package/dist/tools/search-text.js.map +1 -0
- package/dist/tools/utils.d.ts +6 -0
- package/dist/tools/utils.d.ts.map +1 -0
- package/dist/tools/utils.js +14 -0
- package/dist/tools/utils.js.map +1 -0
- package/dist/tools/web-search.d.ts +3 -0
- package/dist/tools/web-search.d.ts.map +1 -0
- package/dist/tools/web-search.js +80 -0
- package/dist/tools/web-search.js.map +1 -0
- package/dist/tools/write-file.d.ts +3 -0
- package/dist/tools/write-file.d.ts.map +1 -0
- package/dist/tools/write-file.js +66 -0
- package/dist/tools/write-file.js.map +1 -0
- package/package.json +54 -0
- package/skills/accessibility/SKILL.md +496 -0
- package/skills/api-design/SKILL.md +419 -0
- package/skills/code-review/SKILL.md +267 -0
- package/skills/debugging/SKILL.md +332 -0
- package/skills/documentation/SKILL.md +496 -0
- package/skills/error-handling/SKILL.md +504 -0
- package/skills/git-workflow/SKILL.md +448 -0
- package/skills/human-like-coding/SKILL.md +400 -0
- package/skills/performance-optimization/SKILL.md +412 -0
- package/skills/prompt-engineering/SKILL.md +362 -0
- package/skills/refactoring/SKILL.md +457 -0
- package/skills/security-audit/SKILL.md +453 -0
- package/skills/testing-strategy/SKILL.md +501 -0
- package/skills/webapp-testing/SKILL.md +309 -0
|
@@ -0,0 +1,362 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: prompt-engineering
|
|
3
|
+
description: Guide for writing effective prompts for AI assistants and LLMs. Use when crafting prompts for code generation, documentation, debugging assistance, or other AI-assisted tasks. Covers prompt structure, context management, and iteration techniques.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Prompt Engineering Skill
|
|
7
|
+
|
|
8
|
+
This skill provides guidance for crafting effective prompts to get better results from AI assistants.
|
|
9
|
+
|
|
10
|
+
## Overview
|
|
11
|
+
|
|
12
|
+
Good prompts lead to better AI outputs. This skill covers techniques for structuring prompts, providing context, and iterating to improve results.
|
|
13
|
+
|
|
14
|
+
## Prompt Structure
|
|
15
|
+
|
|
16
|
+
### Basic Structure
|
|
17
|
+
|
|
18
|
+
```
|
|
19
|
+
[Context] - Background information
|
|
20
|
+
[Task] - What you want done
|
|
21
|
+
[Format] - How you want the output
|
|
22
|
+
[Constraints] - Limitations or requirements
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### Example
|
|
26
|
+
|
|
27
|
+
```
|
|
28
|
+
Context: I'm building a React e-commerce site with TypeScript.
|
|
29
|
+
|
|
30
|
+
Task: Create a product card component that displays an image,
|
|
31
|
+
title, price, and "Add to Cart" button.
|
|
32
|
+
|
|
33
|
+
Format: Provide the component code with TypeScript types.
|
|
34
|
+
|
|
35
|
+
Constraints:
|
|
36
|
+
- Use CSS modules for styling
|
|
37
|
+
- Include hover effects
|
|
38
|
+
- Make it accessible (ARIA labels)
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Effective Prompting Techniques
|
|
42
|
+
|
|
43
|
+
### Be Specific
|
|
44
|
+
|
|
45
|
+
```
|
|
46
|
+
❌ Vague: "Write a function to process data"
|
|
47
|
+
|
|
48
|
+
✓ Specific: "Write a TypeScript function that:
|
|
49
|
+
- Takes an array of user objects with name, email, and age
|
|
50
|
+
- Filters to users over 18
|
|
51
|
+
- Returns a new array with only name and email
|
|
52
|
+
- Sorts by name alphabetically"
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### Provide Context
|
|
56
|
+
|
|
57
|
+
```
|
|
58
|
+
❌ No context: "Fix this bug"
|
|
59
|
+
|
|
60
|
+
✓ With context: "This function should return the sum of all
|
|
61
|
+
positive numbers in the array, but it's returning 0 for
|
|
62
|
+
[1, -2, 3, -4, 5]. The expected result is 9.
|
|
63
|
+
|
|
64
|
+
function sumPositive(numbers) {
|
|
65
|
+
return numbers.filter(n => n > 0).reduce((a, b) => a + b);
|
|
66
|
+
}"
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### Show Examples
|
|
70
|
+
|
|
71
|
+
```
|
|
72
|
+
I want to convert camelCase to kebab-case.
|
|
73
|
+
|
|
74
|
+
Examples:
|
|
75
|
+
- "myVariable" → "my-variable"
|
|
76
|
+
- "handleClick" → "handle-click"
|
|
77
|
+
- "XMLParser" → "xml-parser"
|
|
78
|
+
|
|
79
|
+
Write a function that handles these cases.
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### Specify Format
|
|
83
|
+
|
|
84
|
+
```
|
|
85
|
+
Explain how React's useEffect hook works.
|
|
86
|
+
|
|
87
|
+
Format your response as:
|
|
88
|
+
1. One-sentence summary
|
|
89
|
+
2. When to use it (3 bullet points)
|
|
90
|
+
3. Code example with comments
|
|
91
|
+
4. Common mistakes to avoid
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### Use Step-by-Step Instructions
|
|
95
|
+
|
|
96
|
+
```
|
|
97
|
+
Help me refactor this code. Let's do it step by step:
|
|
98
|
+
|
|
99
|
+
1. First, identify the repeated code patterns
|
|
100
|
+
2. Then, suggest what to extract into separate functions
|
|
101
|
+
3. Show me the refactored code
|
|
102
|
+
4. Explain any tradeoffs
|
|
103
|
+
|
|
104
|
+
[code here]
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## Context Management
|
|
108
|
+
|
|
109
|
+
### Include Relevant Code
|
|
110
|
+
|
|
111
|
+
```
|
|
112
|
+
I'm getting a TypeScript error. Here's the relevant context:
|
|
113
|
+
|
|
114
|
+
// types.ts
|
|
115
|
+
interface User {
|
|
116
|
+
id: string;
|
|
117
|
+
name: string;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// userService.ts
|
|
121
|
+
function getUser(id: number): User { // Error here
|
|
122
|
+
return users.find(u => u.id === id);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
The error says: "Type 'number' is not assignable to type 'string'"
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### Specify Technologies
|
|
129
|
+
|
|
130
|
+
```
|
|
131
|
+
Tech stack:
|
|
132
|
+
- Next.js 14 with App Router
|
|
133
|
+
- TypeScript
|
|
134
|
+
- Prisma with PostgreSQL
|
|
135
|
+
- Tailwind CSS
|
|
136
|
+
|
|
137
|
+
Create an API route that fetches all posts with pagination.
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### Reference Documentation
|
|
141
|
+
|
|
142
|
+
```
|
|
143
|
+
According to React Query v5 docs, queries now use
|
|
144
|
+
object syntax. Update this code to the new format:
|
|
145
|
+
|
|
146
|
+
const { data } = useQuery('users', fetchUsers);
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
## Prompts for Common Tasks
|
|
150
|
+
|
|
151
|
+
### Code Review
|
|
152
|
+
|
|
153
|
+
```
|
|
154
|
+
Review this code for:
|
|
155
|
+
1. Bugs or potential issues
|
|
156
|
+
2. Performance problems
|
|
157
|
+
3. Security vulnerabilities
|
|
158
|
+
4. Code style improvements
|
|
159
|
+
|
|
160
|
+
Don't rewrite the code, just list the issues with
|
|
161
|
+
brief explanations.
|
|
162
|
+
|
|
163
|
+
[code here]
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
### Debugging
|
|
167
|
+
|
|
168
|
+
```
|
|
169
|
+
This function isn't working as expected.
|
|
170
|
+
|
|
171
|
+
Current behavior: [what happens]
|
|
172
|
+
Expected behavior: [what should happen]
|
|
173
|
+
What I've tried: [debugging steps taken]
|
|
174
|
+
|
|
175
|
+
[code here]
|
|
176
|
+
|
|
177
|
+
Help me find the bug.
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
### Explaining Code
|
|
181
|
+
|
|
182
|
+
```
|
|
183
|
+
Explain this code to me:
|
|
184
|
+
- What does it do overall?
|
|
185
|
+
- Walk through it line by line
|
|
186
|
+
- Why might someone write it this way?
|
|
187
|
+
- Are there simpler alternatives?
|
|
188
|
+
|
|
189
|
+
[code here]
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
### Writing Tests
|
|
193
|
+
|
|
194
|
+
```
|
|
195
|
+
Write unit tests for this function using Vitest syntax.
|
|
196
|
+
|
|
197
|
+
Cover these cases:
|
|
198
|
+
1. Normal inputs
|
|
199
|
+
2. Edge cases (empty, null, undefined)
|
|
200
|
+
3. Error conditions
|
|
201
|
+
|
|
202
|
+
[function here]
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
### Documentation
|
|
206
|
+
|
|
207
|
+
```
|
|
208
|
+
Write JSDoc documentation for this function including:
|
|
209
|
+
- Brief description
|
|
210
|
+
- Parameter descriptions with types
|
|
211
|
+
- Return value description
|
|
212
|
+
- Usage example
|
|
213
|
+
- Potential errors thrown
|
|
214
|
+
|
|
215
|
+
[function here]
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
## Iteration Techniques
|
|
219
|
+
|
|
220
|
+
### Refine Incrementally
|
|
221
|
+
|
|
222
|
+
```
|
|
223
|
+
Round 1: "Create a user authentication system"
|
|
224
|
+
↓
|
|
225
|
+
Round 2: "Add password validation requiring 8+ chars,
|
|
226
|
+
one number, and one special character"
|
|
227
|
+
↓
|
|
228
|
+
Round 3: "Add rate limiting to prevent brute force attacks"
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
### Ask for Alternatives
|
|
232
|
+
|
|
233
|
+
```
|
|
234
|
+
You provided Option A. Now show me:
|
|
235
|
+
- Option B: A more performant approach
|
|
236
|
+
- Option C: A more readable approach
|
|
237
|
+
- Which would you recommend and why?
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
### Request Explanations
|
|
241
|
+
|
|
242
|
+
```
|
|
243
|
+
That solution works, but I don't understand why you used
|
|
244
|
+
[specific technique]. Explain the reasoning and show me
|
|
245
|
+
what would happen if I used [alternative] instead.
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
## Anti-Patterns to Avoid
|
|
249
|
+
|
|
250
|
+
### Too Vague
|
|
251
|
+
|
|
252
|
+
```
|
|
253
|
+
❌ "Help me code"
|
|
254
|
+
❌ "Make this better"
|
|
255
|
+
❌ "Write some tests"
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
### Too Much at Once
|
|
259
|
+
|
|
260
|
+
```
|
|
261
|
+
❌ "Build me a complete e-commerce site with user auth,
|
|
262
|
+
payment processing, inventory management, admin
|
|
263
|
+
dashboard, analytics, and mobile app"
|
|
264
|
+
|
|
265
|
+
✓ Break into smaller requests:
|
|
266
|
+
1. "Design the database schema for products and orders"
|
|
267
|
+
2. "Create the product listing API"
|
|
268
|
+
3. "Add shopping cart functionality"
|
|
269
|
+
...
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
### Missing Context
|
|
273
|
+
|
|
274
|
+
```
|
|
275
|
+
❌ "Why doesn't this work?"
|
|
276
|
+
(without showing the code or error)
|
|
277
|
+
|
|
278
|
+
✓ "This code throws 'undefined is not a function' on line 5.
|
|
279
|
+
I expect it to return an array of names.
|
|
280
|
+
[code here]"
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
### Overly Constrained
|
|
284
|
+
|
|
285
|
+
```
|
|
286
|
+
❌ "Write the exact code that will solve my problem
|
|
287
|
+
without any changes needed"
|
|
288
|
+
|
|
289
|
+
✓ "Provide a starting point that I can adapt to my
|
|
290
|
+
specific needs"
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
## Prompt Templates
|
|
294
|
+
|
|
295
|
+
### Feature Implementation
|
|
296
|
+
|
|
297
|
+
```
|
|
298
|
+
Feature: [description]
|
|
299
|
+
|
|
300
|
+
Context:
|
|
301
|
+
- Stack: [technologies]
|
|
302
|
+
- Existing code: [relevant files/functions]
|
|
303
|
+
- Dependencies: [related features]
|
|
304
|
+
|
|
305
|
+
Requirements:
|
|
306
|
+
- [requirement 1]
|
|
307
|
+
- [requirement 2]
|
|
308
|
+
|
|
309
|
+
Constraints:
|
|
310
|
+
- [constraint 1]
|
|
311
|
+
- [constraint 2]
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
### Bug Fix
|
|
315
|
+
|
|
316
|
+
```
|
|
317
|
+
Bug: [brief description]
|
|
318
|
+
|
|
319
|
+
Steps to reproduce:
|
|
320
|
+
1. [step 1]
|
|
321
|
+
2. [step 2]
|
|
322
|
+
|
|
323
|
+
Current behavior: [what happens]
|
|
324
|
+
Expected behavior: [what should happen]
|
|
325
|
+
|
|
326
|
+
Code:
|
|
327
|
+
[relevant code]
|
|
328
|
+
|
|
329
|
+
Error message (if any):
|
|
330
|
+
[error]
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
### Code Explanation
|
|
334
|
+
|
|
335
|
+
```
|
|
336
|
+
Please explain this code:
|
|
337
|
+
|
|
338
|
+
[code]
|
|
339
|
+
|
|
340
|
+
Specifically:
|
|
341
|
+
- What is the purpose?
|
|
342
|
+
- How does [specific part] work?
|
|
343
|
+
- Why use [specific technique]?
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
## Tips for Better Results
|
|
347
|
+
|
|
348
|
+
1. **Start Simple** - Begin with basic requests, add complexity incrementally
|
|
349
|
+
|
|
350
|
+
2. **Use Examples** - Show input/output examples when possible
|
|
351
|
+
|
|
352
|
+
3. **Specify Constraints** - Mention framework versions, coding standards, etc.
|
|
353
|
+
|
|
354
|
+
4. **Ask for Reasoning** - "Explain why" leads to better understanding
|
|
355
|
+
|
|
356
|
+
5. **Iterate** - Don't expect perfection on first try
|
|
357
|
+
|
|
358
|
+
6. **Be Precise** - Ambiguity leads to wrong assumptions
|
|
359
|
+
|
|
360
|
+
7. **Provide Error Messages** - Full error text helps debugging
|
|
361
|
+
|
|
362
|
+
8. **Set Scope** - Define what's in/out of scope clearly
|