.cursor/skills/script-debug/SKILL.md
Systematic debugging workflow for FileMaker scripts — reproduce the issue, isolate the failure point, form a hypothesis, verify with runtime data, and produce a fix. At Tier 1 the developer runs scripts manually and provides debug output. At Tier 3 the agent autonomously instruments the script, deploys the instrumented version, triggers it, reads debug output, and iterates until the root cause is found. Triggers on phrases like "debug this", "script not working", "wrong output", "script error", or when a script produces unexpected behavior.
npx skillsauth add petrowsky/agentic-fm script-debugInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
A systematic debugging workflow: reproduce → isolate → hypothesise → verify → fix. This skill orchestrates the full diagnostic cycle, using fm-debug for runtime data capture.
Read agent/config/automation.json and check project_tier (preferred) or default_tier.
agent/debug/output.json after the developer confirms execution.Gather information from the developer:
Look up the script source from agent/xml_parsed/scripts_sanitized/ and read the human-readable version.
Before forming hypotheses, load the full call tree — the bug may be in a subscript.
Perform Script lines. Extract every target script name.scripts_sanitized/. Use the scripts index: grep "ScriptName" "agent/context/{solution}/scripts.index"Call tree: [Script Name]
├── Subscript A
│ └── Subscript A1
├── Subscript B
└── Subscript C
Flag any Perform Script by name (calculated names) that cannot be statically resolved — ask the developer which scripts may be called at that point.
Understanding the full call tree is critical for debugging because:
Based on the source code and the developer's description, identify the most likely failure points. Common categories:
| Category | Symptoms | What to check |
|---|---|---|
| Error not handled | Works sometimes, fails silently | Missing Get ( LastError ) check after a risky step |
| Wrong layout context | Field shows ?, wrong data | Script assumes a layout but doesn't navigate to it |
| Empty found set | Unexpected behaviour after find | No error 401 handling after Perform Find |
| Stale variable | Wrong value used | Global variable ($$) from a previous run, or variable set in wrong branch |
| Parameter mismatch | Subscript fails or returns wrong result | Caller sends wrong format, callee expects different structure |
| Record locking | Intermittent failures | Error 301 not handled, multi-user contention |
| Server vs client | Works in Pro, fails on server | UI step on server, missing Set Error Capture, layout context issue |
Rank hypotheses by likelihood and identify which runtime data would confirm or eliminate each one.
Generate a debug-instrumented copy of the script. Insert capture points at the identified locations using the fm-debug pattern.
Each debug point is a pair of steps: the single-expression error capture, then a Perform Script call to Agentic-fm Debug.
# DEBUG POINT: [description of what we're checking]
Set Variable [ $errData ; JSONSetElement ( "{}" ;
[ "lastError" ; Get ( LastError ) ; JSONNumber ] ;
[ "lastErrorDetail" ; Get ( LastErrorDetail ) ; JSONString ] ;
[ "lastErrorLocation" ; Get ( LastErrorLocation ) ; JSONString ]
) ]
Perform Script [ "Agentic-fm Debug" ; Parameter: JSONSetElement ( "{}" ;
[ "label" ; "[description]" ; JSONString ] ;
[ "vars" ; JSONSetElement ( "{}" ;
[ "errData" ; $errData ; JSONRaw ] ;
[ "relevantVar" ; $relevantVar ; JSONString ]
) ; JSONRaw ]
) ]
Placement strategy — insert debug points:
Exit Script to capture the final statePerform Script calls to check Get ( ScriptResult )Important: the error capture Set Variable must be the very next step after the risky step. Do not insert a comment step or any other step between them — it would clear the error state.
Look up the Agentic-fm Debug script ID from CONTEXT.json or the scripts index:
grep "Agentic-fm Debug" "agent/context/{solution}/scripts.index"
Generate the instrumented script as fmxmlsnippet in agent/sandbox/ and validate:
python3 agent/scripts/validate_snippet.py agent/sandbox/{ScriptName}.xml
scripts_sanitized/ version is the reference)POST {companion_url}/clipboard, then replace the script content via:
POST {companion_url}/trigger with raw AppleScript: activate FM, open Script Workspace, AXPress the script's tab button, Cmd+A → Delete → Cmd+V → Cmd+SPOST {companion_url}/trigger with { "fm_app_name": "...", "script": "ScriptName", "target_file": "SolutionName" }agent/debug/output.jsonPresent the instrumented script on the clipboard with paste instructions:
The instrumented script is on your clipboard. To install it:
- Open Script Name in Script Workspace
- Cmd+A — select all existing steps and delete
- Cmd+V — paste the debug version
- Run the script with the same inputs that trigger the bug
- Let me know when it's done — I'll read
agent/debug/output.jsondirectly.
After the developer confirms, read agent/debug/output.json
Read agent/debug/output.json and interpret the results:
vars.errData.lastError — the error code captured at the debug point (0 = no error)vars.errData.lastErrorLocation — "ScriptName\rStepName\rLineNumber" if an error occurredCross-reference with the human-readable script to map line numbers to steps.
| Finding | Likely cause | Next step |
|---|---|---|
| lastError: 401 after Perform Find | No records match | Check find criteria, field values |
| lastError: 301 after Set Field | Record locked | Add record locking handling |
| lastError: 0 but wrong variable value | Logic error, not an FM error | Trace the calculation |
| Variable is empty when expected full | Set in a conditional branch that wasn't taken | Check If/Else logic |
| Get ( ScriptResult ) empty after Perform Script | Subscript didn't Exit Script with a result | Check the subscript |
Once the root cause is identified:
agent/sandbox/ — remove all debug instrumentation and apply the fixpython3 agent/scripts/validate_snippet.py agent/sandbox/{ScriptName}.xmlIf the fix doesn't work or the developer wants to revert, the original script is always available in agent/xml_parsed/scripts_sanitized/. At Tier 3, the agent can convert and redeploy the original:
python3 agent/scripts/fm_xml_to_snippet.py "agent/xml_parsed/scripts/{solution}/{path}.xml" "agent/sandbox/{ScriptName}.xml"
Perform Script parameter so the output is self-documentingdevelopment
Generate a complete web application inside a FileMaker Web Viewer — self-contained HTML/CSS/JS styled with the FM theme, plus companion FM bridge scripts for bidirectional data flow. Use when the developer says "web viewer", "webviewer app", "HTML in FileMaker", "build web viewer", or when the layout-design skill delegates to the web-first output path. Recommended for modern, responsive UI, complex interactions (drag-and-drop, charts, rich text), or solutions considering future migration off FileMaker.
development
Trace references to a FileMaker object across the entire solution. Supports usage reports ("where is this field used?"), impact analysis ("what breaks if I rename this?"), and dead object scans ("show unused fields/scripts"). Use when the developer says "trace", "find references", "where is X used", "impact of renaming", "unused fields/scripts", "dead code", "what references X", or "is X used anywhere".
development
Analyze a FileMaker solution and produce a structured profile covering data model, business logic, UI layer, integrations, and health metrics. Uses on-disk pre-processing to handle solutions of any size without sending raw XML through the agent. Use when the developer says "analyze solution", "solution overview", "solution analysis", "solution profile", "solution spec", "what does this solution do", "solution summary", or wants a high-level understanding of an entire FileMaker solution.
development
Interactive setup wizard for agentic-fm. Detects what's already configured, walks the user through each remaining step, and verifies completion before proceeding. Use when the developer says "help me set up", "setup", "get started", "onboard", "first time setup", "install agentic-fm", "configure agentic-fm", or is clearly new to the project and needs guidance.