aoifetch
Version:
A simple Neofetch style system info tool in Node.js, written entirely by gundalf-cli.
63 lines (40 loc) • 2.35 kB
Markdown
# Tips for Guiding AI-Powered Code Generation
To ensure the AI produces modular, maintainable, and idiomatic code, consider adapting your system prompt with the following suggestions:
## 1. Be Explicit About Goals for Code Quality & Style
Don't just describe the feature; also state your expectations:
- Favor modular design: use helper functions, avoid repeated code, keep functions focused.
- Prefer configuration/data-driven solutions (e.g., mapping managers to commands), not long if/else or switch chains.
- Use expressive, descriptive variable and function names.
## 2. Encourage Reusable & Abstracted Logic
Include instructions such as:
- Abstract repeating logic into reusable helpers.
- Use map/object lookups and loops over nearly-identical code branches.
## 3. Demand Safe & Readable Shell Calls
Emphasize:
- Shell/child process calls should be wrapped in safe error handling.
- Place all shell commands in constants/objects when possible, not inline.
- Always safeguard shell and file-system operations.
## 4. Prefer Easy-to-Extend Solutions
Make it clear that you want:
- Designs that are easy to extend (e.g., adding a new package manager should only require an entry in a manager map).
- Special cases should be minimized or eliminated.
## 5. Formatting & Output
Specify preferences like:
- Use consistent formatting in output (e.g., color/highlighting via chalk).
- Specify the order and conventions for outputs.
## Example prompt
> "When you generate or refactor code:
> - Write modular, maintainable, and extensible code.
> - Use mappings and helper functions where possible, not big blocks of if/else.
> - Wrap shell and file operations with error handling and abstraction.
> - Format outputs consistently.
> - Use descriptive variable names.
> - Default to safe operation, always.
> - Do not repeat the same logic in multiple places—abstract it.
> - Only add new package managers by extending a declaration, not by adding new code sections.
>
> Please explain important design choices briefly in your reply."
## The Main Idea
The more you clarify your expectations for modularity, abstraction, data-driven design, and maintainability, the more likely the AI will generate robust, production-quality code. If you'd like, you can further refine or keep a boilerplate of this prompt for future sessions!