home / skills / commontoolsinc / labs / pattern-debug
This skill helps you debug pattern errors systematically by guiding you through TS checks, docs mapping, and minimal reproduction to verify fixes.
npx playbooks add skill commontoolsinc/labs --skill pattern-debugReview the files below or copy the command above to add this skill to your agents.
---
name: pattern-debug
description: Debug pattern errors systematically
user-invocable: false
---
# Debug Pattern
Use `Skill("ct")` for ct CLI documentation if debugging deployment or charm issues.
## Read First
- `docs/development/debugging/workflow.md` - 5-step debugging process
- `docs/development/debugging/README.md` - Error reference matrix
## Process
1. **Check TypeScript errors:**
```bash
deno task ct check pattern.tsx --no-run
```
2. **Match error to documentation:**
- Read the error message carefully
- Check `docs/development/debugging/README.md` for matching errors
3. **Check gotchas:**
- `docs/development/debugging/gotchas/handler-inside-pattern.md`
- `docs/development/debugging/gotchas/filter-map-find-not-a-function.md`
- `docs/development/debugging/gotchas/onclick-inside-computed.md`
4. **Simplify to minimal reproduction:**
- Comment out code until error disappears
- Add back piece by piece to find root cause
5. **Fix and verify:**
- Apply fix
- Run tests to confirm
## Common Issues
**Handler defined inside pattern body:**
- Move handler() to module scope
- Only bind it inside pattern: `onClick={myHandler({ state })}`
**Type errors with Writable/Default:**
- Check if field needs write access → use Writable<>
- Check if field could be undefined → use Default<T, value>
**Action not triggering:**
- Ensure Output type includes action as Stream<void>
- Use .send() not .get() to trigger
## Done When
- Root cause identified
- Error fixed
- Tests pass again
This skill helps you debug pattern-related errors in TypeScript projects systematically. It provides a focused workflow to identify, reproduce, and fix issues related to patterns, handlers, actions, and type mismatches. Use it to accelerate root-cause analysis and verify fixes with tests.
The skill guides you through a five-step debugging process: run a type check, match the error to documented cases, verify common gotchas, reduce the code to a minimal repro, and apply a fix then run tests. It highlights specific checks for handler placement, writable/default type usage, and action triggering semantics so you can quickly pinpoint mistakes. Follow each step in sequence to move from error to verified resolution.
What is the first command I should run?
Start with a static type check on the pattern file, e.g. deno task ct check pattern.tsx --no-run.
Why move handlers to module scope?
Handlers inside the pattern body can cause scoping and re-creation issues; defining them at module scope and binding them in the pattern ensures stable references.