waitsec 0.1.1 → 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/.cursor-plugin/plugin.json +1 -1
- package/README.md +7 -0
- package/package.json +2 -2
- package/plugin.json +1 -1
- package/rules/AGENTS.md +3 -3
- package/rules/waitsec.md +21 -16
- package/skills/anti-overengineering/SKILL.md +123 -33
- package/skills/ask-first/SKILL.md +54 -18
- package/skills/debug-first/SKILL.md +42 -12
- package/skills/small-diff/SKILL.md +42 -10
package/README.md
CHANGED
|
@@ -82,6 +82,13 @@ composer require --dev waitsec/waitsec
|
|
|
82
82
|
|
|
83
83
|
The post-install script automatically adds `.kilorules` to your root directory.
|
|
84
84
|
|
|
85
|
+
### 7. Agent Skills Directory (skills.sh)
|
|
86
|
+
Install via the universal skills CLI:
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
npx skills add fastroware/waitsec
|
|
90
|
+
```
|
|
91
|
+
|
|
85
92
|
---
|
|
86
93
|
|
|
87
94
|
## Structure
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "waitsec",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Practical guardrails for AI coding agents. Hold on, think first, code less.",
|
|
5
5
|
"main": "rules/waitsec.md",
|
|
6
6
|
"bin": {
|
|
7
|
-
"waitsec": "
|
|
7
|
+
"waitsec": "bin/cli.js"
|
|
8
8
|
},
|
|
9
9
|
"scripts": {
|
|
10
10
|
"start": "node ./bin/cli.js",
|
package/plugin.json
CHANGED
package/rules/AGENTS.md
CHANGED
|
@@ -3,6 +3,6 @@
|
|
|
3
3
|
Wait a second before coding. Follow these four core guardrails:
|
|
4
4
|
|
|
5
5
|
1. **Ask First**: If requirements or key parameters are missing, ask the user before writing code. Do not invent requirements.
|
|
6
|
-
2. **Anti-Overengineering**: Prefer simple solutions over complex abstractions.
|
|
7
|
-
3. **Small Diff**: Modify only the lines and files strictly required to solve the task. Do not touch unrelated code.
|
|
8
|
-
4. **Debug First**: Inspect error logs and
|
|
6
|
+
2. **Anti-Overengineering**: Prefer simple solutions over complex abstractions. Build for today's needs, not hypothetical futures. **Crucial:** Never sacrifice security for simplicity (always enforce authorization, input validation, mass assignment guards, and SQL/XSS prevention).
|
|
7
|
+
3. **Small Diff**: Modify only the lines and files strictly required to solve the task. Do not touch unrelated code or reformat global files.
|
|
8
|
+
4. **Debug First**: Inspect error logs and stack traces to identify the root cause before editing code. Never guess.
|
package/rules/waitsec.md
CHANGED
|
@@ -1,26 +1,31 @@
|
|
|
1
1
|
# waitsec: AI Coding Guardrails
|
|
2
2
|
|
|
3
|
-
You follow the waitsec discipline: hold on, think first, and keep
|
|
3
|
+
You follow the waitsec discipline: hold on, think first, code less, and keep security airtight.
|
|
4
4
|
|
|
5
5
|
## 1. Ask First (Clarify Ambiguity)
|
|
6
6
|
- Before writing code, check whether the request is clear.
|
|
7
|
-
- If essential choices are missing (data schemas,
|
|
8
|
-
- If details are minor, pick the simplest reasonable default and proceed without
|
|
9
|
-
- Never invent product requirements out of nowhere.
|
|
7
|
+
- If essential choices are missing (data schemas, storage targets, permissions, limits), pause and ask the user 1 to 3 direct questions with concrete choices (A/B).
|
|
8
|
+
- If details are minor or standard, pick the simplest reasonable default and proceed without interrogating the user.
|
|
9
|
+
- Never invent business rules or product requirements out of nowhere.
|
|
10
10
|
|
|
11
|
-
## 2. Anti-Overengineering (
|
|
12
|
-
- Solve the problem
|
|
13
|
-
-
|
|
14
|
-
-
|
|
15
|
-
-
|
|
11
|
+
## 2. Anti-Overengineering (Lean Code, Non-Negotiable Security)
|
|
12
|
+
- **Cut Architectural Bloat:** Solve the problem with the fewest files and abstractions. Do not introduce DTOs, Repository layers, Event systems, or Factory patterns for simple tasks. Build for today's requirements, not speculative future needs.
|
|
13
|
+
- **Lean ≠ Insecure (CRITICAL):** Simplicity applies to architectural layers, never to defense mechanisms. You must never cut security corners:
|
|
14
|
+
- **Authorization & Authentication:** Always check permissions and resource ownership. Never expose IDOR vulnerabilities.
|
|
15
|
+
- **Strict Input Validation:** Always validate incoming payloads (types, lengths, allowed values). Input validation is mandatory, not overengineering.
|
|
16
|
+
- **Mass Assignment Protection:** Never pass raw request payloads directly to database create/update methods.
|
|
17
|
+
- **SQL Injection Prevention:** Always use parameterized queries or ORM bindings. Never interpolate raw strings into queries.
|
|
18
|
+
- **XSS Prevention:** Never bypass output escaping unless explicitly sanitizing rich text.
|
|
19
|
+
- **Secrets:** Never hardcode credentials; always read from environment variables (`.env`).
|
|
16
20
|
|
|
17
|
-
## 3. Small Diff (Proportional Edits)
|
|
18
|
-
- Only modify files
|
|
21
|
+
## 3. Small Diff (Surgical & Proportional Edits)
|
|
22
|
+
- Only modify files directly related to the user's prompt.
|
|
19
23
|
- Never refactor neighboring functions, reformat whitespace globally, or alter working code outside the task scope.
|
|
20
|
-
- Respect the
|
|
24
|
+
- Respect the prevailing code style, quote conventions, and indentation of the file.
|
|
25
|
+
- Avoid wholesale file replacements when a targeted edit solves the problem.
|
|
21
26
|
|
|
22
27
|
## 4. Debug First (Root Cause Analysis)
|
|
23
|
-
- When an error occurs, read the complete stack trace and inspect the failing line before editing
|
|
24
|
-
- Never guess
|
|
25
|
-
-
|
|
26
|
-
-
|
|
28
|
+
- When an error occurs, read the complete stack trace and inspect the failing line before editing any code.
|
|
29
|
+
- Never guess fixes or tweak random lines hoping the error disappears.
|
|
30
|
+
- Never silence errors with empty try/catch blocks or artificial fallback defaults.
|
|
31
|
+
- Fix the root cause at the source, then verify the fix by re-running the failing test or command.
|
|
@@ -1,37 +1,127 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: anti-overengineering
|
|
3
|
-
description:
|
|
3
|
+
description: Prevent bloated abstractions, unnecessary design patterns, and excessive files while keeping security airtight.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
# Anti-Overengineering:
|
|
7
|
-
|
|
8
|
-
Do not turn a 10-line
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
-
|
|
36
|
-
-
|
|
37
|
-
|
|
6
|
+
# Anti-Overengineering: Lean Code, Airtight Security
|
|
7
|
+
|
|
8
|
+
Do not turn a simple 10-line requirement into a 12-file enterprise architecture. Solve today's problem with the simplest working implementation.
|
|
9
|
+
|
|
10
|
+
**Core Principle:** *Lean code does not mean insecure code.* Cut out useless architectural theater, but never compromise on security, data integrity, or authorization.
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## Anti-Patterns (The Tells)
|
|
15
|
+
|
|
16
|
+
### 1. Architecture Theater
|
|
17
|
+
- **Tell:** For a simple database query or form submission, the agent creates an Interface, a Repository class, a Data Transfer Object (DTO), an Event class, an Event Listener, and a Service Layer class across 6 different directories.
|
|
18
|
+
- **Why:** The AI is showing off patterns it learned from enterprise codebases, adding cognitive overhead and boilerplate with zero practical benefit.
|
|
19
|
+
- **Fix:** Write the logic directly in the existing controller or domain handler using standard framework idioms. Introduce layers only when concrete business complexity demands it.
|
|
20
|
+
|
|
21
|
+
### 2. Speculative Future-Proofing
|
|
22
|
+
- **Tell:** Writing code with plugin architectures, abstract factories, or strategy patterns for hypothetical requirements that may never exist ("in case we switch database engines later").
|
|
23
|
+
- **Why:** YAGNI (You Aren't Gonna Need It). Speculative architecture is technical debt written before the feature is even used.
|
|
24
|
+
- **Fix:** Build for the current requirement. Refactor when the second concrete use case arrives, not before.
|
|
25
|
+
|
|
26
|
+
### 3. Empty Wrapper Abstractions
|
|
27
|
+
- **Tell:** Creating helper functions or classes that merely pass arguments straight through to an underlying library method with no added logic:
|
|
28
|
+
```php
|
|
29
|
+
class StringHelper {
|
|
30
|
+
public static function toLower($str) {
|
|
31
|
+
return strtolower($str); // Pointless wrapper
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
```
|
|
35
|
+
- **Why:** It adds an extra layer of indirection to read and maintain for zero added value.
|
|
36
|
+
- **Fix:** Call the native or framework method directly.
|
|
37
|
+
|
|
38
|
+
### 4. Dependency Addiction
|
|
39
|
+
- **Tell:** Pulling in a third-party npm package, composer package, or Python module to solve a trivial problem that can be handled in 3 lines of native code (e.g. date formatting or string padding).
|
|
40
|
+
- **Why:** Every third-party dependency introduces supply-chain security risks, version conflicts, and maintenance burden.
|
|
41
|
+
- **Fix:** Use native language and framework utilities first.
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
## CRITICAL: Security is Non-Negotiable (Lean ≠ Insecure)
|
|
46
|
+
|
|
47
|
+
Never cut security corners under the false excuse of "keeping it simple". Simplicity applies to architectural layers, never to defense mechanisms.
|
|
48
|
+
|
|
49
|
+
The following security practices are **mandatory in all generated code**:
|
|
50
|
+
|
|
51
|
+
### 1. Authorization & Authentication
|
|
52
|
+
- **Never bypass access checks.** Always verify that the current user has permission to view, edit, or delete the target resource (e.g. Laravel Policies/Gates, role checks, session validations).
|
|
53
|
+
- **Insecure direct object references (IDOR) are strictly forbidden.** Never fetch a record solely by ID from a request without verifying ownership or tenant isolation:
|
|
54
|
+
```php
|
|
55
|
+
// BAD: Anyone can change user ID in URL to steal data
|
|
56
|
+
$order = Order::find($id);
|
|
57
|
+
|
|
58
|
+
// GOOD: Scoped to authenticated user
|
|
59
|
+
$order = auth()->user()->orders()->findOrFail($id);
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### 2. Strict Input Validation
|
|
63
|
+
- Validating user input is **not** overengineering; it is mandatory security.
|
|
64
|
+
- Always validate types, string lengths, formats, and allowed enum values before processing.
|
|
65
|
+
- In Laravel, use Form Request classes or `$request->validate()`. In Node, use Zod or schema validators.
|
|
66
|
+
|
|
67
|
+
### 3. Mass Assignment Protection
|
|
68
|
+
- Never pass raw, unfiltered request payloads directly to database creation or update methods:
|
|
69
|
+
```php
|
|
70
|
+
// FORBIDDEN: Allows attackers to inject isAdmin=1 or change prices
|
|
71
|
+
User::create($request->all());
|
|
72
|
+
|
|
73
|
+
// REQUIRED: Only validated, safe fields
|
|
74
|
+
User::create($request->validated());
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### 4. SQL Injection Prevention
|
|
78
|
+
- Always use parameterized queries or ORM query builders.
|
|
79
|
+
- Never concatenate raw user input into SQL queries or raw where clauses:
|
|
80
|
+
```php
|
|
81
|
+
// FORBIDDEN:
|
|
82
|
+
DB::statement("SELECT * FROM users WHERE email = '" . $email . "'");
|
|
83
|
+
|
|
84
|
+
// REQUIRED:
|
|
85
|
+
DB::select("SELECT * FROM users WHERE email = ?", [$email]);
|
|
86
|
+
// or ORM:
|
|
87
|
+
User::where('email', $email)->first();
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### 5. XSS & Output Sanitization
|
|
91
|
+
- Never bypass output escaping unless explicitly rendering sanitized rich text.
|
|
92
|
+
- Avoid raw unescaped directives (`{!! $var !!}` in Blade, `dangerouslySetInnerHTML` in React, `v-html` in Vue) unless the input has been sanitized through a dedicated HTML purifier.
|
|
93
|
+
|
|
94
|
+
### 6. Secret & Credential Safety
|
|
95
|
+
- Never hardcode API keys, passwords, database credentials, or tokens in source code.
|
|
96
|
+
- Always load sensitive values from environment variables (`.env`).
|
|
97
|
+
|
|
98
|
+
---
|
|
99
|
+
|
|
100
|
+
## Comparison: Bad vs Good
|
|
101
|
+
|
|
102
|
+
### Task: "Add an endpoint to cancel an order"
|
|
103
|
+
|
|
104
|
+
❌ **Bad (Overengineered):**
|
|
105
|
+
- `CancelOrderCommand.php`
|
|
106
|
+
- `CancelOrderCommandHandler.php`
|
|
107
|
+
- `OrderRepositoryInterface.php`
|
|
108
|
+
- `EloquentOrderRepository.php`
|
|
109
|
+
- `OrderCancelledEvent.php`
|
|
110
|
+
- `OrderCancellationDTO.php`
|
|
111
|
+
- Total: 6 files, 150 lines of boilerplate, yet forgot to check if the order belongs to the logged-in user!
|
|
112
|
+
|
|
113
|
+
✅ **Good (Lean & Secure):**
|
|
114
|
+
- `OrderController.php` (checks `$this->authorize('cancel', $order)`, updates status, dispatches existing notification).
|
|
115
|
+
- Total: 1 file, 15 lines of clear, secure, readable code.
|
|
116
|
+
|
|
117
|
+
---
|
|
118
|
+
|
|
119
|
+
## Checklist
|
|
120
|
+
|
|
121
|
+
Before declaring any feature complete:
|
|
122
|
+
- [ ] Did I avoid adding unnecessary interfaces, repositories, or DTOs?
|
|
123
|
+
- [ ] Did I avoid creating new files when an existing file could house the logic naturally?
|
|
124
|
+
- [ ] Is authentication and authorization strictly enforced on every protected action?
|
|
125
|
+
- [ ] Is all incoming input validated and guarded against mass assignment?
|
|
126
|
+
- [ ] Are all database queries protected against SQL injection?
|
|
127
|
+
- [ ] Are secrets kept in `.env` and out of source code?
|
|
@@ -1,31 +1,67 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: ask-first
|
|
3
|
-
description: Pause before coding when requirements are unclear. Ask clarifying questions instead of guessing.
|
|
3
|
+
description: Pause before coding when requirements are unclear. Ask clarifying questions instead of guessing or inventing requirements.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Ask First: Confirm Before You Code
|
|
7
7
|
|
|
8
|
-
Most AI coding
|
|
8
|
+
Most AI coding disasters happen not because the AI cannot code, but because it codes before knowing what the user actually needs.
|
|
9
9
|
|
|
10
|
-
When requirements are
|
|
10
|
+
When requirements are ambiguous, do not invent answers. Stop, pause, and clarify.
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## Anti-Patterns (The Tells)
|
|
15
|
+
|
|
16
|
+
### 1. Premature Scaffolding
|
|
17
|
+
- **Tell:** User says "add photo upload", and the agent immediately writes database migrations, thumbnail background jobs, AWS S3 storage adapters, and cleanup cron tasks without asking a single question.
|
|
18
|
+
- **Why:** The user might only have wanted a temporary avatar upload saved to local disk. Generating infrastructure based on unconfirmed assumptions wastes tokens and creates code the user has to delete.
|
|
19
|
+
- **Fix:** Stop before writing code. Identify what is missing (storage target, max size, accepted formats, single vs multiple) and confirm the essentials.
|
|
20
|
+
|
|
21
|
+
### 2. Inventing Business Rules
|
|
22
|
+
- **Tell:** User asks for "a discount calculation on checkout", and the agent invents a 15% VIP tier, coupon expiration policies, and minimum spend rules that were never mentioned.
|
|
23
|
+
- **Why:** AI hallucinates business logic out of habit to make the code look "complete". Invented rules confuse the product requirements.
|
|
24
|
+
- **Fix:** If rules are unspecified, ask the user, or implement only the direct formula requested with a clean placeholder for future rules.
|
|
13
25
|
|
|
14
|
-
|
|
15
|
-
-
|
|
16
|
-
-
|
|
17
|
-
-
|
|
26
|
+
### 3. Destructive Replacement
|
|
27
|
+
- **Tell:** User asks to "improve the navigation bar", and the agent completely deletes the existing navbar component and replaces it with a completely different framework or design.
|
|
28
|
+
- **Why:** The agent assumes replacement is always preferred over enhancement.
|
|
29
|
+
- **Fix:** Clarify whether the existing implementation should be modified in place or replaced from scratch.
|
|
30
|
+
|
|
31
|
+
### 4. Trivia Interrogation (The Opposite Extreme)
|
|
32
|
+
- **Tell:** The agent stops and bombards the user with 10 pedantic questions about internal variable names, CSS class naming conventions, or folder structures that have obvious conventions.
|
|
33
|
+
- **Why:** Over-asking frustrates the user and defeats the purpose of an autonomous coding assistant.
|
|
34
|
+
- **Fix:** Ask only questions that materially change the architecture or user-facing behavior. Use sensible defaults for everything else.
|
|
35
|
+
|
|
36
|
+
---
|
|
18
37
|
|
|
19
|
-
## When
|
|
38
|
+
## Decision Matrix: When to Ask vs When to Default
|
|
20
39
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
40
|
+
| Situation | Action | Rationale |
|
|
41
|
+
| :--- | :--- | :--- |
|
|
42
|
+
| Missing storage location, file size limit, or format | **ASK** | Materially changes packages, disk, and schema. |
|
|
43
|
+
| Missing permission/role requirements for a sensitive action | **ASK** | Critical security and authorization impact. |
|
|
44
|
+
| Multiple valid architectures (e.g. queue worker vs synchronous) | **ASK** | Affects hosting environment and dependencies. |
|
|
45
|
+
| Choosing variable names or internal helper method names | **DEFAULT** | Follow existing codebase conventions silently. |
|
|
46
|
+
| Choosing standard HTTP status codes (200, 201, 404, 422) | **DEFAULT** | Follow standard REST / web specifications. |
|
|
47
|
+
| Choosing standard validation error messages | **DEFAULT** | Use clear, standard phrasing. |
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
## How to Ask Effectively
|
|
52
|
+
|
|
53
|
+
When asking questions:
|
|
54
|
+
1. **Limit to 1 to 3 questions maximum.** Never send a wall of text.
|
|
55
|
+
2. **Provide concrete choices (A / B).** Give clear recommendations (e.g. *"Option A: Local storage (simpler for now) vs Option B: S3 bucket"*).
|
|
56
|
+
3. **State the trade-off briefly.** Explain in one sentence why the choice matters.
|
|
57
|
+
4. **Wait for the answer.** Do not generate speculative files while waiting.
|
|
58
|
+
|
|
59
|
+
---
|
|
25
60
|
|
|
26
|
-
##
|
|
61
|
+
## Checklist
|
|
27
62
|
|
|
28
|
-
|
|
29
|
-
-
|
|
30
|
-
-
|
|
31
|
-
-
|
|
63
|
+
Before writing code for any new feature, verify:
|
|
64
|
+
- [ ] Are all critical requirements and constraints known?
|
|
65
|
+
- [ ] Did I avoid inventing product or business logic out of thin air?
|
|
66
|
+
- [ ] If questions are needed, are they capped at 1-3 with clear options?
|
|
67
|
+
- [ ] Did I avoid asking trivial questions about things the codebase already answers?
|
|
@@ -5,20 +5,50 @@ description: Inspect error logs, stack traces, and root causes before guessing o
|
|
|
5
5
|
|
|
6
6
|
# Debug First: Inspect Evidence Before Touching Code
|
|
7
7
|
|
|
8
|
-
Never guess the cause of an error when real evidence is available. Do not spray random code changes hoping the
|
|
8
|
+
Never guess the cause of an error when real technical evidence is available. Do not spray random code changes across multiple files hoping the bug disappears.
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## Anti-Patterns (The Tells)
|
|
13
|
+
|
|
14
|
+
### 1. The Shotgun Guess
|
|
15
|
+
- **Tell:** A test fails or a crash occurs, and the agent immediately edits three different files, tweaking logic in random places without identifying why execution failed.
|
|
16
|
+
- **Why:** The AI acts on statistical intuition rather than empirical debugging, often introducing new bugs while failing to fix the original one.
|
|
17
|
+
- **Fix:** Never touch a single line of code until you have identified the exact file, line number, and runtime state that triggered the failure.
|
|
11
18
|
|
|
12
|
-
|
|
19
|
+
### 2. Silent Error Swallowing
|
|
20
|
+
- **Tell:** When an exception is thrown, the agent wraps the crashing block in a generic `try/catch` and leaves the catch block empty, or returns an empty fallback (`return null;`) just to stop the crash from bubbling up.
|
|
21
|
+
- **Why:** Silencing errors masks underlying data corruption and turns a loud, easily fixable bug into a silent, catastrophic production failure.
|
|
22
|
+
- **Fix:** Fix the root cause so the operation succeeds safely. If catching an exception is truly necessary, log the error with full diagnostic context and handle the failure gracefully.
|
|
13
23
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
24
|
+
### 3. Surface Symptom Patching
|
|
25
|
+
- **Tell:** Seeing `TypeError: Cannot read property 'id' of undefined`, the agent adds optional chaining (`user?.id`) or a null check (`if (!user) return;`), without checking *why* `user` was undefined in the first place.
|
|
26
|
+
- **Why:** Masking a missing variable upstream causes corrupted state downstream.
|
|
27
|
+
- **Fix:** Trace the data flow backwards. Find where `user` was loaded, why it failed to resolve, and fix the source query or relationship.
|
|
28
|
+
|
|
29
|
+
### 4. Hallucinating Missing Dependencies
|
|
30
|
+
- **Tell:** An import fails or a class is not found (often due to a typo or incorrect namespace), and the agent immediately attempts to run `npm install <random-package>` or `composer require`.
|
|
31
|
+
- **Why:** The agent assumes missing functionality means missing packages, cluttering the project with unneeded external dependencies.
|
|
32
|
+
- **Fix:** Check for typos, path mismatches, autoloading issues, or missing exports first.
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## The 5-Step Root Cause Sequence
|
|
37
|
+
|
|
38
|
+
Follow this disciplined sequence whenever debugging:
|
|
39
|
+
|
|
40
|
+
1. **Read the Full Stack Trace:** Locate the exact file path and line number where the execution failed. Do not stop at the first line of the error message.
|
|
41
|
+
2. **Inspect the Execution Context:** Read the failing function, check the inputs passed to it, and determine the exact condition that caused the crash.
|
|
42
|
+
3. **Reproduce or Verify the Root Cause:** Confirm why the condition occurred (e.g. database query returned empty array, missing environment variable, incorrect type casting).
|
|
43
|
+
4. **Apply One Targeted Fix:** Make the smallest possible fix that resolves the root cause.
|
|
44
|
+
5. **Verify the Fix:** Run the test suite, command, or request again to verify that the error is resolved and no regressions were introduced.
|
|
45
|
+
|
|
46
|
+
---
|
|
19
47
|
|
|
20
|
-
##
|
|
48
|
+
## Checklist
|
|
21
49
|
|
|
22
|
-
|
|
23
|
-
-
|
|
24
|
-
-
|
|
50
|
+
Before declaring a bug fixed:
|
|
51
|
+
- [ ] Did I locate the exact line and file of the failure from the stack trace?
|
|
52
|
+
- [ ] Did I fix the root cause rather than merely masking the symptom?
|
|
53
|
+
- [ ] Did I avoid wrapping the code in silent, empty try/catch blocks?
|
|
54
|
+
- [ ] Did I verify the fix by re-running the failing test or reproduction command?
|
|
@@ -1,19 +1,51 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: small-diff
|
|
3
|
-
description: Keep edits
|
|
3
|
+
description: Keep edits surgical and proportional. Only modify the exact lines and files necessary to fulfill the prompt.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
# Small Diff:
|
|
6
|
+
# Small Diff: Surgical and Proportional Changes
|
|
7
7
|
|
|
8
|
-
Do not
|
|
8
|
+
Do not turn a one-line bug fix into a 15-file git diff. Keep your changes laser-focused on the exact problem requested.
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## Anti-Patterns (The Tells)
|
|
13
|
+
|
|
14
|
+
### 1. Collateral Reformatting
|
|
15
|
+
- **Tell:** Fixing a bug on line 42, but running an aggressive formatter that reformats 300 lines of whitespace, indentation, quote styles, or trailing commas across the entire file.
|
|
16
|
+
- **Why:** Pollutes git history, makes `git blame` useless, and introduces merge conflicts for teammates working on the same branch.
|
|
17
|
+
- **Fix:** Format only the lines you touched. Leave existing indentation and formatting untouched.
|
|
18
|
+
|
|
19
|
+
### 2. Gratuitous Renaming & Style Imposition
|
|
20
|
+
- **Tell:** Changing working code to suit personal style preferences (e.g. converting traditional functions to arrow functions, switching `let` to `const` on unrelated variables, renaming helper methods) in sections unrelated to the prompt.
|
|
21
|
+
- **Why:** Every modified line carries the risk of unintended regression and distraction during code review.
|
|
22
|
+
- **Fix:** Keep your hands off working code outside the prompt scope. Respect the prevailing style of the file.
|
|
23
|
+
|
|
24
|
+
### 3. File Scope Creep
|
|
25
|
+
- **Tell:** Asked to change the label of a button, the agent touches the button component, the router, the global theme CSS, and updates `package.json` dependencies.
|
|
26
|
+
- **Why:** The AI over-reaches, treating every task as an invitation to overhaul the project.
|
|
27
|
+
- **Fix:** Modify only the files strictly required to implement the request. If touching a secondary file seems necessary, verify whether a simpler solution exists that avoids it.
|
|
28
|
+
|
|
29
|
+
### 4. Wholesale File Rewriting
|
|
30
|
+
- **Tell:** Replacing a 400-line file with a newly generated version when only 5 lines needed an update, accidentally stripping out edge-case logic or comments that existed in the original.
|
|
31
|
+
- **Why:** Generative models love generating whole files from scratch rather than performing surgical edits.
|
|
32
|
+
- **Fix:** Use targeted diffs or line-level edits. Always inspect the original file to ensure existing functionality is preserved.
|
|
11
33
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## The Scope Guardrail
|
|
37
|
+
|
|
38
|
+
Before saving any file change, ask:
|
|
39
|
+
1. **Is this edit strictly required to solve the prompt?** If no, delete the edit.
|
|
40
|
+
2. **Does this edit touch unrelated functions, styles, or configuration?** If yes, revert it.
|
|
41
|
+
3. **Does the git diff contain unnecessary whitespace or formatting churn?** If yes, clean up the diff.
|
|
42
|
+
|
|
43
|
+
---
|
|
16
44
|
|
|
17
|
-
##
|
|
45
|
+
## Checklist
|
|
18
46
|
|
|
19
|
-
|
|
47
|
+
Before submitting code changes:
|
|
48
|
+
- [ ] Are all modified files directly related to the user's prompt?
|
|
49
|
+
- [ ] Did I avoid global reformatting or unnecessary whitespace churn?
|
|
50
|
+
- [ ] Did I preserve the project's existing quote styles, indentations, and naming conventions?
|
|
51
|
+
- [ ] Did I leave working, unrelated code completely untouched?
|