Skip to content

Commit 7366c62

Browse files
Enhance prompting documentation with comprehensive guidance
- Add platform-specific guidance for Slack, Linear, and GitHub - Include common task type examples (code review, bug fixing, feature dev, refactoring) - Add advanced techniques section with context provision and iterative prompting - Include troubleshooting section for common issues - Add best practices cards and getting help section - Expand examples to be more realistic and diverse - Maintain existing structure while significantly expanding practical value
1 parent ac96b79 commit 7366c62

File tree

1 file changed

+186
-2
lines changed

1 file changed

+186
-2
lines changed

docs/introduction/prompting.mdx

Lines changed: 186 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ To get the best results from Codegen, treat it like a skilled teammate: provide
99

1010
<Tip>
1111
Codegen is based on Anthropic's Claude 3.7. You can prompt it similarly to
12-
ChatGPT or other LLM-based assistants
12+
ChatGPT or other LLM-based assistants, but with access to powerful development tools.
1313
</Tip>
1414

1515
## The Core Principle: Specificity
@@ -30,7 +30,191 @@ If there are specific implementation details you want included, make sure to spe
3030
4. **Context/Patterns:** Are there existing patterns, examples, or documentation to reference? (e.g., `ProductService`, `ProductRepository`)
3131
5. **Success Criteria:** How will you know the task is done correctly? (e.g., Tests pass, 90%+ coverage, diagram updated)
3232

33+
## Platform-Specific Guidance
34+
35+
### Slack Integration
36+
When prompting Codegen in Slack:
37+
- **Use threads** for complex, multi-step requests to keep context organized
38+
- **Tag specific repos** early in the conversation: "In the `frontend` repo..."
39+
- **Reference PR numbers** directly: "Review PR #123 and suggest improvements"
40+
- **Ask for status updates** on long-running tasks: "What's the progress on the refactoring?"
41+
42+
Example Slack prompt:
43+
```
44+
@codegen In the `api-server` repo, can you:
45+
1. Add input validation to the `/users` endpoint
46+
2. Use the same validation pattern as `/products`
47+
3. Add tests covering edge cases
48+
4. Update the OpenAPI spec
49+
50+
Let me know when you have a PR ready! 🚀
51+
```
52+
53+
### Linear Integration
54+
When working with Linear issues:
55+
- **Reference issue numbers** for context: "This relates to CG-1234"
56+
- **Break down large tasks** into sub-issues when appropriate
57+
- **Specify acceptance criteria** clearly in the issue description
58+
- **Use @codegen** to assign implementation tasks directly
59+
60+
Example Linear prompt:
61+
```
62+
@codegen Please implement the user authentication feature described in this issue.
63+
64+
Requirements:
65+
- JWT-based auth with refresh tokens
66+
- Follow the security patterns in `auth/oauth.ts`
67+
- Add middleware for protected routes
68+
- Include comprehensive tests
69+
- Update the API documentation
70+
71+
This should integrate with the existing user management system.
72+
```
73+
74+
### GitHub Integration
75+
When requesting PR reviews or code changes:
76+
- **Link to specific files** and line numbers when possible
77+
- **Reference related issues** or previous PRs for context
78+
- **Specify review criteria**: security, performance, maintainability
79+
- **Request specific types of feedback**: "Focus on error handling"
80+
81+
Example GitHub prompt:
82+
```
83+
@codegen Please review this PR focusing on:
84+
1. Security implications of the new auth flow
85+
2. Performance impact of the database queries
86+
3. Test coverage for edge cases
87+
88+
Also check if the error handling follows our patterns in `utils/errors.ts`.
89+
```
90+
91+
## Common Task Types
92+
93+
### Code Review
94+
```
95+
Review PR #456 in the `backend` repo and check for:
96+
- SQL injection vulnerabilities
97+
- Proper error handling
98+
- Performance bottlenecks
99+
- Test coverage gaps
100+
- Documentation updates needed
101+
```
102+
103+
### Bug Fixing
104+
```
105+
There's a memory leak in the `data-processor` service when handling large files.
106+
- Investigate the issue in `src/processors/file-handler.ts`
107+
- Look at similar fixes in `image-processor.ts`
108+
- Add monitoring to prevent future occurrences
109+
- Include regression tests
110+
```
111+
112+
### Feature Development
113+
```
114+
Implement a real-time notification system:
115+
- Use WebSockets for live updates
116+
- Follow the event pattern in `events/user-events.ts`
117+
- Add rate limiting (max 10 notifications/minute)
118+
- Support both browser and mobile clients
119+
- Include end-to-end tests
120+
```
121+
122+
### Refactoring
123+
```
124+
Refactor the payment processing module to improve testability:
125+
- Extract external API calls into separate services
126+
- Add dependency injection
127+
- Follow the repository pattern used in `user-service`
128+
- Maintain backward compatibility
129+
- Achieve 95%+ test coverage
130+
```
131+
132+
## Advanced Techniques
133+
134+
### Providing Context Effectively
135+
When working with large codebases:
136+
137+
```
138+
In the `e-commerce` monorepo, I need to add a new payment method.
139+
Context:
140+
- Existing payment methods are in `src/payments/methods/`
141+
- The `PaymentProcessor` interface is in `src/payments/types.ts`
142+
- Configuration is handled in `config/payments.json`
143+
- Tests follow the pattern in `tests/payments/stripe.test.ts`
144+
145+
Please implement Apple Pay support following these existing patterns.
146+
```
147+
148+
### Iterative Prompting
149+
Build on previous work:
150+
151+
```
152+
Following up on the authentication PR you created:
153+
- The security team wants 2FA support added
154+
- Use the same JWT structure but add a `requires_2fa` claim
155+
- Integrate with the existing `TwoFactorService`
156+
- Update the login flow to handle 2FA challenges
157+
```
158+
159+
### Handling Complex Dependencies
160+
For interconnected changes:
161+
162+
```
163+
I need to update the user model across multiple services:
164+
1. Add `preferences` field to User model in `user-service`
165+
2. Update the GraphQL schema in `api-gateway`
166+
3. Modify the frontend components in `web-app/src/components/user/`
167+
4. Add database migration scripts
168+
5. Update all related tests
169+
170+
Please coordinate these changes and create PRs in the correct order.
171+
```
172+
173+
## Troubleshooting Common Issues
174+
175+
### "I don't have enough context"
176+
**Problem:** Codegen asks for more information
177+
**Solution:** Provide file paths, existing patterns, and specific requirements upfront
178+
179+
### "The changes broke existing functionality"
180+
**Problem:** Modifications caused test failures
181+
**Solution:** Always specify which tests should continue passing and request regression testing
182+
183+
### "The implementation doesn't match our patterns"
184+
**Problem:** Code doesn't follow team conventions
185+
**Solution:** Reference specific examples of preferred patterns in your codebase
186+
187+
### "The task is too large"
188+
**Problem:** Request is overwhelming or unclear
189+
**Solution:** Break down into smaller, specific tasks with clear dependencies
190+
191+
## Best Practices
192+
193+
<CardGroup cols={2}>
194+
<Card title="Be Specific" icon="target">
195+
Include file paths, function names, and exact requirements rather than general descriptions.
196+
</Card>
197+
<Card title="Provide Examples" icon="code">
198+
Reference existing code patterns, similar implementations, or desired outcomes.
199+
</Card>
200+
<Card title="Set Success Criteria" icon="check-circle">
201+
Define what "done" looks like: passing tests, performance metrics, or specific functionality.
202+
</Card>
203+
<Card title="Consider Dependencies" icon="link">
204+
Mention related systems, APIs, or components that might be affected by changes.
205+
</Card>
206+
</CardGroup>
207+
33208
<Note>
34209
Clear, detailed prompts empower Codegen agents to deliver accurate results
35-
faster, significantly streamlining your workflow.
210+
faster, significantly streamlining your workflow. Remember that Codegen has access
211+
to your entire codebase and can understand complex relationships between files.
36212
</Note>
213+
214+
## Getting Help
215+
216+
If you're unsure how to structure a prompt for your specific use case:
217+
- Start with a simple request and iterate based on the results
218+
- Ask Codegen to suggest how to break down complex tasks
219+
- Reference the [capabilities documentation](/introduction/capabilities) to understand available tools
220+
- Check out real examples in our [use cases section](/use-cases)

0 commit comments

Comments
 (0)