@bobmatnyc/ai-code-review
Version:
A TypeScript-based tool for automated code reviews using AI models from Google Gemini, Anthropic Claude, and OpenRouter
91 lines (67 loc) • 4.29 kB
Markdown
This directory contains a structured system for managing, maintaining, and sharing prompts used by the AI Code Review tool. The system uses a templating approach with Handlebars to provide flexible, reusable prompt components with variable substitution.
```
promptText/
├── common/
│ ├── css-frameworks/
│ ├── output-formats/
│ └── variables/
│ ├── css-frameworks.json
│ └── framework-versions.json
├── frameworks/
│ ├── react/
│ ├── angular/
│ ├── vue/
│ ├── nextjs/
│ ├── django/
│ ├── fastapi/
│ ├── flask/
│ ├── pyramid/
│ └── laravel/
└── languages/
├── typescript/
├── python/
├── php/
└── ruby/
```
The prompt system uses Handlebars templates (`.hbs` files) that support:
1. **Variable Substitution**: Insert dynamic values using `{{variableName}}` syntax
2. **Partials**: Include shared components with `{{> common/path/to/partial}}`
3. **Conditional Logic**: Use `{{
4. **Loops and Iteration**: Process lists with `{{
5. **Helpers**: Custom formatting functions like `{{
Variables are loaded from JSON files in the `common/variables/` directory:
- `framework-versions.json`: Contains version information and features for each framework
- `css-frameworks.json`: Contains version information and features for CSS frameworks
To reference these variables in templates:
```handlebars
Latest Angular version is {{frameworks.angular.latest.version}} released in {{frameworks.angular.latest.releaseDate}}
```
Common template sections can be included with:
```handlebars
{{> common/css-frameworks/tailwind-section}}
```
1. Create a new `.hbs` file in the appropriate directory
2. Use standard Handlebars syntax for variables and partials
3. Make sure to end your review template with the standard output format:
```handlebars
{{> common/output-formats/standard-review-format language="PYTHON" framework="DJANGO"
impactAreas="type safety, maintainability, or performance"
improvementFocus="adherence to Django best practices"
includeVersionCompatibility=true
versionsList="5.2, 4.2, or both"}}
```
When the application runs, templates are loaded, compiled with appropriate variables, and made available to the bundledPrompts system. This happens at runtime, allowing for dynamic template updates without rebuilding the application.
1. Update framework versions in the JSON files when new versions are released
2. Keep template styles consistent and focused on actionable recommendations
3. When adding new frameworks, follow the existing directory structure
This prompt management system replaces the old approach where prompts were defined directly in `src/prompts/bundledPrompts.ts` and duplicated across language directories in `/prompts`. This new approach is more maintainable, easier to update, and provides consistent formatting and versioning across all prompt types.