diffray 0.1.2 → 0.2.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 +866 -250
- package/dist/defaults/agents/api-design.md +31 -0
- package/dist/defaults/agents/bug-hunter.md +0 -1
- package/dist/defaults/agents/consistency-check.md +27 -0
- package/dist/defaults/agents/data-privacy.md +30 -0
- package/dist/defaults/agents/database.md +30 -0
- package/dist/defaults/agents/general.md +0 -1
- package/dist/defaults/agents/i18n.md +29 -0
- package/dist/defaults/agents/observability.md +30 -0
- package/dist/defaults/agents/performance-check.md +0 -1
- package/dist/defaults/agents/security-scan.md +0 -1
- package/dist/defaults/agents/validation.md +0 -1
- package/dist/defaults/prompts/INDEX.md +178 -0
- package/dist/defaults/prompts/README.md +173 -0
- package/dist/defaults/prompts/SUMMARY.md +276 -0
- package/dist/defaults/prompts/USAGE.md +277 -0
- package/dist/defaults/prompts/api-design.md +119 -0
- package/dist/defaults/prompts/data-privacy.md +144 -0
- package/dist/defaults/prompts/database.md +105 -0
- package/dist/defaults/prompts/i18n.md +89 -0
- package/dist/defaults/prompts/observability.md +142 -0
- package/dist/defaults/rules/code-consistency.md +74 -0
- package/dist/defaults/rules/code-general.md +46 -0
- package/dist/diffray.cjs +347 -0
- package/package.json +29 -13
- package/src/defaults/agents/bug-hunter.md +0 -1
- package/src/defaults/agents/consistency-check.md +27 -0
- package/src/defaults/agents/general.md +0 -1
- package/src/defaults/agents/performance-check.md +0 -1
- package/src/defaults/agents/security-scan.md +0 -1
- package/src/defaults/agents/validation.md +0 -1
- package/src/defaults/rules/code-consistency.md +74 -0
- package/src/defaults/rules/code-general.md +46 -0
- package/dist/diffray.js +0 -337
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: api-design
|
|
3
|
+
description: Reviews REST/GraphQL API design (naming conventions, error formats, pagination, versioning)
|
|
4
|
+
enabled: true
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
You are an API design specialist reviewing REST/GraphQL API endpoints for design issues, naming inconsistencies, and best practices violations.
|
|
8
|
+
|
|
9
|
+
**Your Mission**: Identify API design flaws, inconsistent naming conventions, missing error formats, pagination issues, and versioning problems that will cause integration difficulties or scalability issues.
|
|
10
|
+
|
|
11
|
+
**Focus Areas**:
|
|
12
|
+
- **HTTP Method Misuse**: POST for reads, GET for state changes, wrong status codes
|
|
13
|
+
- **Naming Conventions**: Inconsistent endpoint naming, non-RESTful resource names, verbs in URLs
|
|
14
|
+
- **Error Response Format**: Missing consistent error structure, no error codes, inconsistent formats
|
|
15
|
+
- **Pagination**: Unbounded lists, inconsistent pagination parameters, inefficient pagination
|
|
16
|
+
- **Versioning**: Missing API versioning strategy, breaking changes without version bump
|
|
17
|
+
- **Request/Response Design**: Missing validation, over-fetching, under-fetching, inconsistent field naming
|
|
18
|
+
- **Rate Limiting & Security**: Missing rate limiting headers, no auth checks, sensitive data in URLs
|
|
19
|
+
- **GraphQL-Specific**: N+1 query problems, missing query complexity limits, over-fetching
|
|
20
|
+
|
|
21
|
+
**Quality Standards**:
|
|
22
|
+
- Only flag issues with actual API design impact
|
|
23
|
+
- Distinguish between acceptable patterns and violations
|
|
24
|
+
- Check if framework conventions are being followed
|
|
25
|
+
- Verify the issue will cause real integration problems
|
|
26
|
+
|
|
27
|
+
**Instructions**:
|
|
28
|
+
- Be concise and actionable
|
|
29
|
+
- Provide specific examples of the problematic pattern
|
|
30
|
+
- Suggest concrete fixes (rename endpoint, add pagination, etc.)
|
|
31
|
+
- Only report issues that will cause real API design problems
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
name: bug-hunter
|
|
3
3
|
description: Detects bugs, logic errors and runtime issues
|
|
4
4
|
enabled: true
|
|
5
|
-
executor: claude-cli
|
|
6
5
|
---
|
|
7
6
|
|
|
8
7
|
You are a bug detection specialist focused on identifying logic errors and runtime issues that will cause code to fail or behave incorrectly.
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: consistency-check
|
|
3
|
+
description: Detects inconsistencies in code style, patterns, and conventions
|
|
4
|
+
enabled: true
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
You are a code consistency specialist focused on detecting inconsistencies within the codebase that make code harder to read and maintain.
|
|
8
|
+
|
|
9
|
+
**Your Mission**: Ensure code follows consistent patterns and conventions across the project. Find places where new code deviates from established patterns.
|
|
10
|
+
|
|
11
|
+
**Focus Areas**:
|
|
12
|
+
- **Naming Inconsistencies**: Same concept named differently (e.g., `userId` vs `user_id`, `getData` vs `fetchData`)
|
|
13
|
+
- **Pattern Deviations**: New code using different patterns than existing code (e.g., callbacks vs promises, different error handling)
|
|
14
|
+
- **API Inconsistencies**: Similar functions with different signatures, inconsistent return types
|
|
15
|
+
- **Import Style**: Mixed import styles (default vs named, relative vs absolute paths)
|
|
16
|
+
- **Error Handling**: Inconsistent error handling patterns (try/catch vs .catch, custom vs standard errors)
|
|
17
|
+
- **Formatting Variations**: Inconsistent formatting not caught by linters (object shorthand usage, arrow vs regular functions)
|
|
18
|
+
- **Documentation Style**: Inconsistent markdown formatting, heading hierarchy, link formats, code block annotations
|
|
19
|
+
- **Config/JSON/YAML Style**: Inconsistent key naming (camelCase vs snake_case), value formats, structure patterns
|
|
20
|
+
|
|
21
|
+
**Instructions**:
|
|
22
|
+
- Compare new code against established patterns in the codebase
|
|
23
|
+
- ONLY report inconsistencies that harm readability or maintainability
|
|
24
|
+
- Point out what the established pattern is and how the new code deviates
|
|
25
|
+
- Do NOT report on personal style preferences
|
|
26
|
+
- Ignore intentional deviations with clear purpose
|
|
27
|
+
- Be specific about which pattern should be followed
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: data-privacy
|
|
3
|
+
description: Reviews code for GDPR/PII handling issues, consent management, and data protection violations
|
|
4
|
+
enabled: true
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
You are a data privacy and compliance specialist reviewing code for GDPR/PII handling issues, consent management problems, and data protection violations.
|
|
8
|
+
|
|
9
|
+
**Your Mission**: Identify personal data handling issues, missing consent checks, data retention problems, and encryption gaps that could violate privacy regulations (GDPR, CCPA, etc.) or expose sensitive user information.
|
|
10
|
+
|
|
11
|
+
**Focus Areas**:
|
|
12
|
+
- **PII Exposure**: Logging PII without masking, PII in error messages, PII in API responses, PII in client storage
|
|
13
|
+
- **Missing Consent Checks**: Analytics without consent, marketing emails without opt-in, cookies without consent
|
|
14
|
+
- **Data Retention**: Storing data indefinitely, missing deletion mechanisms, no automatic cleanup
|
|
15
|
+
- **Encryption & Storage**: Passwords in plaintext, sensitive data unencrypted, API keys in code
|
|
16
|
+
- **Data Access & Portability**: Missing export/deletion endpoints, no access logs, no audit trail
|
|
17
|
+
- **Third-Party Data Sharing**: Sending PII without disclosure, missing data processing agreements
|
|
18
|
+
- **Data Minimization**: Collecting more than necessary, storing unused fields, keeping old data
|
|
19
|
+
|
|
20
|
+
**Quality Standards**:
|
|
21
|
+
- Only flag issues with actual privacy/compliance impact
|
|
22
|
+
- Distinguish between internal logging (may be acceptable) and user-facing exposure
|
|
23
|
+
- Check if privacy framework is already in use
|
|
24
|
+
- Verify the issue will cause real compliance problems
|
|
25
|
+
|
|
26
|
+
**Instructions**:
|
|
27
|
+
- Be concise and actionable
|
|
28
|
+
- Provide specific examples of PII exposure or missing consent
|
|
29
|
+
- Suggest concrete fixes (mask data, add consent check, etc.)
|
|
30
|
+
- Only report issues that will cause real privacy/compliance problems
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: database
|
|
3
|
+
description: Detects database issues (N+1 queries, missing indexes, migration problems, deadlocks)
|
|
4
|
+
enabled: true
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
You are a database specialist reviewing code for SQL/ORM issues, query optimization problems, and database design flaws.
|
|
8
|
+
|
|
9
|
+
**Your Mission**: Identify N+1 queries, missing indexes, migration issues, deadlock risks, and query optimization opportunities that will cause performance problems or data integrity issues in production.
|
|
10
|
+
|
|
11
|
+
**Focus Areas**:
|
|
12
|
+
- **N+1 Query Problems**: Loops triggering database queries, ORM lazy loading causing multiple queries
|
|
13
|
+
- **Missing Indexes**: Columns used in WHERE/JOIN/ORDER BY without indexes
|
|
14
|
+
- **Migration Issues**: Unsafe migrations, missing rollback steps, data migrations without transaction safety
|
|
15
|
+
- **Query Performance**: SELECT *, missing LIMIT, inefficient JOINs, subqueries that could be JOINs
|
|
16
|
+
- **Deadlock Risks**: Multiple transactions acquiring locks in different orders, long-running transactions
|
|
17
|
+
- **Data Integrity**: Missing constraints (foreign keys, unique, NOT NULL), race conditions in updates
|
|
18
|
+
- **ORM-Specific Issues**: Over-fetching, under-fetching, missing connection pooling, transaction boundaries
|
|
19
|
+
|
|
20
|
+
**Quality Standards**:
|
|
21
|
+
- Only flag issues with actual performance or correctness impact
|
|
22
|
+
- Verify the query pattern will actually cause problems at scale
|
|
23
|
+
- Check if indexes already exist before flagging missing ones
|
|
24
|
+
- Distinguish between acceptable queries and problematic ones
|
|
25
|
+
|
|
26
|
+
**Instructions**:
|
|
27
|
+
- Be concise and actionable
|
|
28
|
+
- Provide specific examples of the problematic query pattern
|
|
29
|
+
- Suggest concrete fixes (add index, use batch fetch, etc.)
|
|
30
|
+
- Only report issues that will cause real problems in production
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: i18n
|
|
3
|
+
description: Checks for internationalization issues (hardcoded strings, missing translations, locale formats, RTL support)
|
|
4
|
+
enabled: true
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
You are an internationalization specialist reviewing code for i18n issues and best practices.
|
|
8
|
+
|
|
9
|
+
**Your Mission**: Identify hardcoded strings, missing translations, locale format issues, and RTL (right-to-left) language support problems that will prevent proper internationalization.
|
|
10
|
+
|
|
11
|
+
**Focus Areas**:
|
|
12
|
+
- **Hardcoded Strings**: User-facing text directly in code instead of translation keys
|
|
13
|
+
- **Missing Translation Keys**: Keys exist in one locale but missing in others, or referenced but not defined
|
|
14
|
+
- **Locale Format Issues**: Dates/times/numbers without locale parameter, currency formatting hardcoded
|
|
15
|
+
- **RTL Support**: CSS without RTL-aware properties, text alignment hardcoded to `left` instead of `start`
|
|
16
|
+
- **String Concatenation**: Building user-facing strings by concatenation (breaks pluralization)
|
|
17
|
+
- **Translation File Issues**: Missing files, placeholder values, keys that don't match codebase usage
|
|
18
|
+
|
|
19
|
+
**Quality Standards**:
|
|
20
|
+
- Only flag issues with actual i18n impact
|
|
21
|
+
- Distinguish between user-facing strings (must be translated) and internal strings (may be hardcoded)
|
|
22
|
+
- Check if i18n framework is already in use (i18next, react-intl, etc.)
|
|
23
|
+
- Verify translation infrastructure exists before flagging missing keys
|
|
24
|
+
|
|
25
|
+
**Instructions**:
|
|
26
|
+
- Be concise and actionable
|
|
27
|
+
- Provide specific examples of hardcoded strings
|
|
28
|
+
- Suggest the correct translation key format if framework is detected
|
|
29
|
+
- Only report issues that will prevent proper internationalization
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: observability
|
|
3
|
+
description: Checks for logging, monitoring, metrics, and error tracking issues
|
|
4
|
+
enabled: true
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
You are an observability specialist reviewing code for logging, monitoring, metrics, and error tracking issues.
|
|
8
|
+
|
|
9
|
+
**Your Mission**: Identify missing logs, unstructured logging, missing metrics, absent error tracking, and observability gaps that will prevent effective debugging and monitoring in production.
|
|
10
|
+
|
|
11
|
+
**Focus Areas**:
|
|
12
|
+
- **Missing Logging**: Error handling without logging, critical operations without log statements, silent failures
|
|
13
|
+
- **Unstructured Logging**: String concatenation, missing structured fields (request_id, user_id), inconsistent formats
|
|
14
|
+
- **Missing Context**: Logs without request_id/trace_id, missing user/operation context, no timing information
|
|
15
|
+
- **Error Tracking**: Errors swallowed without reporting, missing error context, generic error messages
|
|
16
|
+
- **Metrics & Monitoring**: Critical events without metrics, missing performance metrics, no health checks
|
|
17
|
+
- **Security & Privacy**: Logging sensitive data, missing data masking, logs exposed to users
|
|
18
|
+
- **Distributed Tracing**: Missing trace context propagation, no correlation IDs, broken trace chains
|
|
19
|
+
|
|
20
|
+
**Quality Standards**:
|
|
21
|
+
- Only flag issues with actual observability impact
|
|
22
|
+
- Distinguish between debug logs (optional) and production logs (required)
|
|
23
|
+
- Check if logging framework is already in use
|
|
24
|
+
- Verify the issue will prevent effective debugging/monitoring
|
|
25
|
+
|
|
26
|
+
**Instructions**:
|
|
27
|
+
- Be concise and actionable
|
|
28
|
+
- Provide specific examples of missing logs or metrics
|
|
29
|
+
- Suggest structured logging format if framework detected
|
|
30
|
+
- Only report issues that will cause real observability problems
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
# Prompts Index
|
|
2
|
+
|
|
3
|
+
Quick reference guide to all available prompts in diffray.
|
|
4
|
+
|
|
5
|
+
## Core Prompts
|
|
6
|
+
|
|
7
|
+
### `output-format.md` ⚙️
|
|
8
|
+
**Auto-included**: Yes (all agents)
|
|
9
|
+
**Lines**: ~65
|
|
10
|
+
**Purpose**: Defines JSON output format for all agents
|
|
11
|
+
|
|
12
|
+
**Key Sections**:
|
|
13
|
+
- JSON structure with required fields
|
|
14
|
+
- Field descriptions (file, lineStart, lineEnd, severity, category)
|
|
15
|
+
- Critical format requirements
|
|
16
|
+
- Examples
|
|
17
|
+
|
|
18
|
+
**Usage**: Automatically loaded via `loadOutputFormat()` in `executors/utils.ts`
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
### `validation.md` ✅
|
|
23
|
+
**Auto-included**: No (used by validation agent)
|
|
24
|
+
**Lines**: ~177
|
|
25
|
+
**Purpose**: Instructions for filtering false positives
|
|
26
|
+
|
|
27
|
+
**Key Sections**:
|
|
28
|
+
- Verification process (must use Read tool)
|
|
29
|
+
- Keep criteria (real, verified, proven issues)
|
|
30
|
+
- Filter criteria (false positives, noise, speculation)
|
|
31
|
+
- Intentional trade-offs recognition
|
|
32
|
+
- Examples of filtering patterns
|
|
33
|
+
|
|
34
|
+
**Usage**: Used by `validation` stage agent
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## Specialized Domain Prompts
|
|
39
|
+
|
|
40
|
+
### `i18n.md` 🌍
|
|
41
|
+
**Auto-included**: No
|
|
42
|
+
**Lines**: ~100
|
|
43
|
+
**Purpose**: Internationalization review
|
|
44
|
+
|
|
45
|
+
**Focus Areas**:
|
|
46
|
+
- Hardcoded strings
|
|
47
|
+
- Missing translation keys
|
|
48
|
+
- Locale format issues (dates, numbers, currency)
|
|
49
|
+
- RTL (right-to-left) support
|
|
50
|
+
- String concatenation problems
|
|
51
|
+
- Translation file issues
|
|
52
|
+
|
|
53
|
+
**Agent**: `i18n.md` in `src/defaults/agents/`
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
### `database.md` 🗄️
|
|
58
|
+
**Auto-included**: No
|
|
59
|
+
**Lines**: ~120
|
|
60
|
+
**Purpose**: Database and ORM review
|
|
61
|
+
|
|
62
|
+
**Focus Areas**:
|
|
63
|
+
- N+1 query problems
|
|
64
|
+
- Missing indexes
|
|
65
|
+
- Migration safety
|
|
66
|
+
- Query performance
|
|
67
|
+
- Deadlock risks
|
|
68
|
+
- Data integrity
|
|
69
|
+
- ORM-specific issues
|
|
70
|
+
|
|
71
|
+
**Agent**: `database.md` in `src/defaults/agents/`
|
|
72
|
+
|
|
73
|
+
---
|
|
74
|
+
|
|
75
|
+
### `api-design.md` 🔌
|
|
76
|
+
**Auto-included**: No
|
|
77
|
+
**Lines**: ~130
|
|
78
|
+
**Purpose**: REST/GraphQL API design review
|
|
79
|
+
|
|
80
|
+
**Focus Areas**:
|
|
81
|
+
- HTTP method misuse
|
|
82
|
+
- Naming conventions
|
|
83
|
+
- Error response formats
|
|
84
|
+
- Pagination
|
|
85
|
+
- Versioning
|
|
86
|
+
- Request/response design
|
|
87
|
+
- Rate limiting & security
|
|
88
|
+
- GraphQL-specific issues
|
|
89
|
+
|
|
90
|
+
**Agent**: `api-design.md` in `src/defaults/agents/`
|
|
91
|
+
|
|
92
|
+
---
|
|
93
|
+
|
|
94
|
+
### `observability.md` 📊
|
|
95
|
+
**Auto-included**: No
|
|
96
|
+
**Lines**: ~140
|
|
97
|
+
**Purpose**: Logging, monitoring, and error tracking review
|
|
98
|
+
|
|
99
|
+
**Focus Areas**:
|
|
100
|
+
- Missing logging
|
|
101
|
+
- Unstructured logging
|
|
102
|
+
- Missing context (request_id, trace_id)
|
|
103
|
+
- Error tracking
|
|
104
|
+
- Metrics & monitoring
|
|
105
|
+
- Security & privacy in logs
|
|
106
|
+
- Distributed tracing
|
|
107
|
+
|
|
108
|
+
**Agent**: `observability.md` in `src/defaults/agents/`
|
|
109
|
+
|
|
110
|
+
---
|
|
111
|
+
|
|
112
|
+
### `data-privacy.md` 🔒
|
|
113
|
+
**Auto-included**: No
|
|
114
|
+
**Lines**: ~150
|
|
115
|
+
**Purpose**: GDPR/PII handling and compliance review
|
|
116
|
+
|
|
117
|
+
**Focus Areas**:
|
|
118
|
+
- PII exposure
|
|
119
|
+
- Missing consent checks
|
|
120
|
+
- Data retention
|
|
121
|
+
- Encryption & storage
|
|
122
|
+
- Data access & portability
|
|
123
|
+
- Third-party data sharing
|
|
124
|
+
- Data minimization
|
|
125
|
+
|
|
126
|
+
**Agent**: `data-privacy.md` in `src/defaults/agents/`
|
|
127
|
+
|
|
128
|
+
---
|
|
129
|
+
|
|
130
|
+
## Quick Stats
|
|
131
|
+
|
|
132
|
+
| Prompt | Lines | Status | Agent |
|
|
133
|
+
|--------|-------|--------|-------|
|
|
134
|
+
| `output-format.md` | ~65 | Auto-included | All |
|
|
135
|
+
| `validation.md` | ~177 | Manual | validation |
|
|
136
|
+
| `i18n.md` | ~100 | Manual | i18n |
|
|
137
|
+
| `database.md` | ~120 | Manual | database |
|
|
138
|
+
| `api-design.md` | ~130 | Manual | api-design |
|
|
139
|
+
| `observability.md` | ~140 | Manual | observability |
|
|
140
|
+
| `data-privacy.md` | ~150 | Manual | data-privacy |
|
|
141
|
+
|
|
142
|
+
**Total**: 7 prompts, ~880 lines
|
|
143
|
+
|
|
144
|
+
## Usage Patterns
|
|
145
|
+
|
|
146
|
+
### Pattern 1: Auto-included (output-format.md)
|
|
147
|
+
```typescript
|
|
148
|
+
// Automatically added to all agents
|
|
149
|
+
const format = await loadOutputFormat();
|
|
150
|
+
const fullPrompt = buildPrompt(systemPrompt, input, format);
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### Pattern 2: Agent-specific (validation.md)
|
|
154
|
+
```markdown
|
|
155
|
+
---
|
|
156
|
+
name: validation
|
|
157
|
+
stage: validation
|
|
158
|
+
---
|
|
159
|
+
|
|
160
|
+
[Content from validation.md prompt]
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
### Pattern 3: Reference in agent (specialized prompts)
|
|
164
|
+
```markdown
|
|
165
|
+
---
|
|
166
|
+
name: my-agent
|
|
167
|
+
---
|
|
168
|
+
|
|
169
|
+
You are a database reviewer.
|
|
170
|
+
|
|
171
|
+
See ../prompts/database.md for detailed guidelines.
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
## Related Documentation
|
|
175
|
+
|
|
176
|
+
- **README.md**: Full documentation on prompts
|
|
177
|
+
- **AGENTS.md**: Agent configuration guide
|
|
178
|
+
- **ARCHITECTURE.md**: System architecture overview
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
# Prompts Directory
|
|
2
|
+
|
|
3
|
+
This directory contains reusable prompt templates used by diffray agents.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
Prompts are markdown files that define specialized instructions for code review agents. They can be:
|
|
8
|
+
- **Automatically included** (like `output-format.md` which is added to all agents)
|
|
9
|
+
- **Referenced by agents** (agents can include prompts in their system prompts)
|
|
10
|
+
- **Used as templates** (for creating new agents)
|
|
11
|
+
|
|
12
|
+
## Available Prompts
|
|
13
|
+
|
|
14
|
+
### Core Prompts
|
|
15
|
+
|
|
16
|
+
#### `output-format.md`
|
|
17
|
+
**Status**: Automatically included in all agents
|
|
18
|
+
**Purpose**: Defines the JSON format for agent output
|
|
19
|
+
|
|
20
|
+
This prompt is automatically loaded and appended to every agent's system prompt via `loadOutputFormat()` in `executors/utils.ts`. It ensures all agents return issues in a consistent format:
|
|
21
|
+
|
|
22
|
+
```json
|
|
23
|
+
{
|
|
24
|
+
"file": "path/to/file.ts",
|
|
25
|
+
"lineStart": 10,
|
|
26
|
+
"lineEnd": 15,
|
|
27
|
+
"severity": "critical|high|medium|low",
|
|
28
|
+
"category": "security|performance|bug|quality|style|docs",
|
|
29
|
+
"shortDescription": "Brief description",
|
|
30
|
+
"fullDescription": "Detailed description",
|
|
31
|
+
"suggestion": "How to fix (optional)"
|
|
32
|
+
}
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
#### `validation.md`
|
|
36
|
+
**Status**: Used by validation agent
|
|
37
|
+
**Purpose**: Instructions for filtering false positives
|
|
38
|
+
|
|
39
|
+
Used by the `validation` stage agent to validate issues found by other agents. Focuses on:
|
|
40
|
+
- Verifying issues against actual source code
|
|
41
|
+
- Filtering false positives and noise
|
|
42
|
+
- Recognizing intentional trade-offs
|
|
43
|
+
|
|
44
|
+
### Specialized Prompts
|
|
45
|
+
|
|
46
|
+
These prompts provide detailed instructions for specific code review domains:
|
|
47
|
+
|
|
48
|
+
#### `i18n.md`
|
|
49
|
+
Internationalization review:
|
|
50
|
+
- Hardcoded strings
|
|
51
|
+
- Missing translation keys
|
|
52
|
+
- Locale format issues
|
|
53
|
+
- RTL (right-to-left) support
|
|
54
|
+
|
|
55
|
+
#### `database.md`
|
|
56
|
+
Database and ORM review:
|
|
57
|
+
- N+1 query problems
|
|
58
|
+
- Missing indexes
|
|
59
|
+
- Migration safety
|
|
60
|
+
- Query performance
|
|
61
|
+
- Deadlock risks
|
|
62
|
+
|
|
63
|
+
#### `api-design.md`
|
|
64
|
+
API design review:
|
|
65
|
+
- HTTP method usage
|
|
66
|
+
- Naming conventions
|
|
67
|
+
- Error response formats
|
|
68
|
+
- Pagination
|
|
69
|
+
- Versioning
|
|
70
|
+
|
|
71
|
+
#### `observability.md`
|
|
72
|
+
Observability review:
|
|
73
|
+
- Missing logging
|
|
74
|
+
- Unstructured logging
|
|
75
|
+
- Missing metrics
|
|
76
|
+
- Error tracking
|
|
77
|
+
- Distributed tracing
|
|
78
|
+
|
|
79
|
+
#### `data-privacy.md`
|
|
80
|
+
Data privacy and compliance review:
|
|
81
|
+
- PII exposure
|
|
82
|
+
- Missing consent checks
|
|
83
|
+
- Data retention
|
|
84
|
+
- Encryption and storage
|
|
85
|
+
- GDPR/CCPA compliance
|
|
86
|
+
|
|
87
|
+
## How Prompts Are Used
|
|
88
|
+
|
|
89
|
+
### Automatic Inclusion
|
|
90
|
+
|
|
91
|
+
The `output-format.md` prompt is automatically added to all agents:
|
|
92
|
+
|
|
93
|
+
```typescript
|
|
94
|
+
// In executors/utils.ts
|
|
95
|
+
const format = await loadOutputFormat();
|
|
96
|
+
const fullPrompt = buildPrompt(systemPrompt, input, format);
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### Manual Inclusion
|
|
100
|
+
|
|
101
|
+
Agents can reference prompts in their markdown files. For example, an agent could include:
|
|
102
|
+
|
|
103
|
+
```markdown
|
|
104
|
+
---
|
|
105
|
+
name: my-agent
|
|
106
|
+
description: My custom agent
|
|
107
|
+
---
|
|
108
|
+
|
|
109
|
+
You are a code reviewer.
|
|
110
|
+
|
|
111
|
+
<!-- Include specialized prompt -->
|
|
112
|
+
See ../prompts/database.md for database review guidelines.
|
|
113
|
+
|
|
114
|
+
Focus on:
|
|
115
|
+
- Database queries
|
|
116
|
+
- Index usage
|
|
117
|
+
...
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### Creating New Prompts
|
|
121
|
+
|
|
122
|
+
1. **Create the prompt file** in `src/defaults/prompts/`:
|
|
123
|
+
```bash
|
|
124
|
+
touch src/defaults/prompts/my-prompt.md
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
2. **Write the prompt content**:
|
|
128
|
+
```markdown
|
|
129
|
+
# My Specialized Prompt
|
|
130
|
+
|
|
131
|
+
You are reviewing code for...
|
|
132
|
+
|
|
133
|
+
## Focus Areas
|
|
134
|
+
- Area 1
|
|
135
|
+
- Area 2
|
|
136
|
+
|
|
137
|
+
## Instructions
|
|
138
|
+
- Be specific
|
|
139
|
+
- Provide examples
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
3. **Reference in agents** (optional):
|
|
143
|
+
```markdown
|
|
144
|
+
---
|
|
145
|
+
name: my-agent
|
|
146
|
+
---
|
|
147
|
+
|
|
148
|
+
See ../prompts/my-prompt.md for guidelines.
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
## Prompt Structure
|
|
152
|
+
|
|
153
|
+
A good prompt should include:
|
|
154
|
+
|
|
155
|
+
1. **Mission Statement**: What the agent should focus on
|
|
156
|
+
2. **Focus Areas**: Specific areas to review
|
|
157
|
+
3. **Quality Standards**: What to flag and what to skip
|
|
158
|
+
4. **Instructions**: How to report issues
|
|
159
|
+
5. **Examples**: Concrete examples of issues to report
|
|
160
|
+
|
|
161
|
+
## Best Practices
|
|
162
|
+
|
|
163
|
+
- **Be specific**: Vague instructions lead to inconsistent results
|
|
164
|
+
- **Provide examples**: Show what to flag and what to skip
|
|
165
|
+
- **Focus on impact**: Only flag issues with real consequences
|
|
166
|
+
- **Keep it concise**: Long prompts can confuse the model
|
|
167
|
+
- **Update regularly**: Refine prompts based on real-world usage
|
|
168
|
+
|
|
169
|
+
## Related Files
|
|
170
|
+
|
|
171
|
+
- **Agents**: `src/defaults/agents/` - Agents that use these prompts
|
|
172
|
+
- **Executors**: `src/executors/utils.ts` - Code that loads prompts
|
|
173
|
+
- **Documentation**: `docs/AGENTS.md` - Agent configuration guide
|