Skip to content

Commit 472a49c

Browse files
brannnclaude
andcommitted
Teach planner to write flat, simple rules to avoid branch miscounts
Changed guidance from counting branches to writing simple rules: - One condition per rule (avoid "if A and B") - Split compound conditions into separate rules - Add 1-2 extra examples to be safe - Updated cart example to show flat rule structure Should prevent E012 errors from complex nested conditionals. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent e282c92 commit 472a49c

1 file changed

Lines changed: 17 additions & 10 deletions

File tree

web/cmd/server/static/js/simplex-spec.js

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -298,11 +298,13 @@ const BASE_SYSTEM_PROMPT = `Generate Simplex v0.5 specifications. Follow this st
298298
6. ERRORS: (inside FUNCTION) - error conditions
299299
300300
**CRITICAL RULES:**
301-
1. Count EVERY "if" condition in RULES (including "if not", "if no", "if empty", etc.)
302-
2. You MUST provide EXACTLY that many EXAMPLES (or more)
303-
3. Each conditional branch = one example. 6 branches = 6 examples minimum
304-
4. This is STRICTLY ENFORCED - specs will FAIL validation if examples < branches
305-
5. Always end ERRORS with: "any unhandled condition → fail with descriptive message"
301+
1. Write simple, flat RULES - one condition per rule
302+
2. Avoid compound conditions like "if A and B" - split into separate rules
303+
3. Count total "if" statements = minimum EXAMPLES needed
304+
4. EVERY rule with "if" needs an example showing that path
305+
5. Add 1-2 extra examples to be safe - better too many than too few
306+
6. STRICTLY ENFORCED - specs FAIL if examples < branches
307+
7. Always end ERRORS with: "any unhandled condition → fail with descriptive message"
306308
307309
**Optional landmarks (inside FUNCTION, use when spec requires):**
308310
- READS: Shared memory this function consumes (multi-agent coordination)
@@ -336,22 +338,27 @@ ERRORS:
336338
- any unhandled condition → fail with descriptive message
337339
\`\`\`
338340
339-
With DATA types:
341+
With DATA types (note: flat, simple rules):
340342
\`\`\`
341343
DATA: Cart
342344
items: list of Item
343345
total: number
344346
347+
DATA: Item
348+
id: integer
349+
price: number
350+
345351
FUNCTION: add_item(cart: Cart, item: Item) → Cart
346352
347353
RULES:
348354
- if cart is empty, create new cart with item
349-
- if cart has items and item exists, increment quantity
350-
- if cart has items and item is new, append to list
355+
- if item already in cart, increment its quantity
356+
- if item not in cart, append to items list
357+
- recalculate total price
351358
352359
DONE_WHEN:
353-
- item appears in cart
354-
- total reflects item price
360+
- item appears in cart with correct quantity
361+
- total reflects all item prices
355362
356363
EXAMPLES:
357364
(Cart{items: [], total: 0}, Item{id: 1, price: 10}) → Cart{items: [Item{id:1, qty:1}], total: 10}

0 commit comments

Comments
 (0)