Skip to content

Commit a3f192c

Browse files
seefeldbellyxircubic-dev-ai[bot]
authored
docs(common): iteratively improved prompts (#1926)
* shopping list pattern + feedback * feedback applied * next round of shopping patterns and feedback * improved docs based on last feedback * third round + feedback * updated docs based on feedback * newest version of pattern * use onct-change instead of onchange * style should be object * fix deno fmt complaints * fix list item numbering * fix formatting for shopping-list-categorized.tsx * added id for the integration test * need to grab index to pass it into key() * Update docs/common/PATTERNS.md Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com> * fix references to findIndex to pass index parameter * made a seperate cell to track the category drop down, it was sharing with the first drop down * remove OpaqueRef example in handler and dont use index for removing item in arrays * fix mentions of onChange to onct-change for example code * updated removeItem references to use item.equals() rather than index for arrays in doc * fix css style into objects * fix various mistakes that crept in * fixed a bunch of wrong advice here -- noticing a lot of duplication but leaving it alone for now * some minor edits * remove extra files from generation process --------- Co-authored-by: Ellyse <ellyse7777@gmail.com> Co-authored-by: Ellyse <141240083+ellyxir@users.noreply.github.com> Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
1 parent 7b2cdc2 commit a3f192c

File tree

9 files changed

+2528
-162
lines changed

9 files changed

+2528
-162
lines changed

.claude/commands/recipe-dev.md

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,79 @@ Before working on recipes it is recommended to search for `COMPONENTS.md` and `R
4646

4747
Read `HANDLERS.md` when confused about event handler errors.
4848

49+
## Development Workflow Best Practices
50+
51+
When developing and testing patterns iteratively, follow this workflow:
52+
53+
### Step-by-Step Development Process
54+
55+
1. **Check Syntax** (Optional - only if requested or deployment fails):
56+
```bash
57+
./dist/ct dev pattern.tsx --no-run
58+
```
59+
This validates TypeScript/JSX syntax without executing the pattern.
60+
61+
2. **Test Execution Locally** (Optional):
62+
```bash
63+
./dist/ct dev pattern.tsx
64+
```
65+
This runs the pattern in a local test environment. Useful for catching runtime errors.
66+
67+
3. **Deploy to Test Space**:
68+
```bash
69+
./dist/ct charm new --identity [keyfile] --api-url [api-url] --space [spacename] pattern.tsx
70+
```
71+
Deployment will automatically compile and validate the recipe. Record the CHARM_ID returned.
72+
73+
4. **Iterate with setsrc**:
74+
```bash
75+
./dist/ct charm setsrc --identity [keyfile] --api-url [api-url] --space [spacename] --charm [charm-id] pattern.tsx
76+
```
77+
Update the charm without creating a new one. Much faster for iteration.
78+
79+
5. **Inspect and Debug**:
80+
```bash
81+
# View charm data and outputs
82+
./dist/ct charm inspect --identity [keyfile] --api-url [api-url] --space [spacename] --charm [charm-id]
83+
84+
# Get specific field values
85+
./dist/ct charm get --identity [keyfile] --api-url [api-url] --space [spacename] --charm [charm-id] items/0/name
86+
87+
# Set test data
88+
echo '{"name": "Test Item"}' | ./dist/ct charm set --identity [keyfile] --api-url [api-url] --space [spacename] --charm [charm-id] testData
89+
```
90+
91+
### Common Error Patterns and Solutions
92+
93+
**Type Errors:**
94+
- Missing `OpaqueRef<T>` type on array map parameters
95+
- Using `Cell<Array<Cell<T>>>` instead of `Cell<T[]>` in handlers
96+
- Forgetting to import `ID` when using `[ID]`
97+
98+
**Runtime Errors:**
99+
- Trying to use DOM access (`document.getElementById`)
100+
- Using conditionals (if/ternary) instead of `ifElse`
101+
- Calling `llm()` from within handlers or lift functions
102+
103+
**Deployment Errors:**
104+
- Import path issues (use relative imports like `./file.tsx`)
105+
- Missing dependencies in the recipe
106+
- Syntax errors that weren't caught locally
107+
108+
**Data Not Updating:**
109+
- Forgetting `$` prefix for bidirectional binding
110+
- Handler not being called (check event names match)
111+
- Cell not being passed to handler correctly
112+
113+
### Tips for Efficient Development
114+
115+
- **Don't pre-test syntax** unless deployment fails - the deployment process validates automatically
116+
- **Use `inspect` frequently** to understand current state
117+
- **Use `get/set` commands** to manually test data transformations
118+
- **Keep handler definitions at module level** for better reusability
119+
- **Start simple** then add complexity incrementally
120+
- **Check example patterns** in `packages/patterns/` for reference
121+
49122
#### Workflow A: Modifying Existing Recipes
50123

51124
**Get recipe source:**

0 commit comments

Comments
 (0)