.cursor/skills/fm-debug/SKILL.md
Debug a FileMaker script by capturing runtime state. At Tier 1 the agent instruments the script and gives the developer run instructions. At Tier 3 the agent can autonomously look up the script source, generate a debug-instrumented copy, deploy it via AppleScript, trigger it via the companion, and read the results — no human intervention required. Triggers on phrases like "debug this", "script not working", "wrong output", "script error", or when a script produces unexpected behavior that cannot be diagnosed from source alone.
npx skillsauth add petrowsky/agentic-fm fm-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.
Debug a FileMaker script by capturing runtime variable state, error codes, and error locations. The agent's level of autonomy depends on the deployment tier configured in agent/config/automation.json.
Read agent/config/automation.json and check project_tier (preferred) or default_tier:
Tier 2 follows the Tier 3 workflow for running scripts (via /trigger) but cannot create new scripts autonomously.
Before generating any instrumentation:
agent/debug/output.json. If it exists and is recent, read it and skip to Step 5.agent/xml_parsed/scripts_sanitized/ to understand the script's logic and identify where to insert debug instrumentation.Get ( LastError ) resets the error state as a side effect. Once evaluated, Get ( LastErrorLocation ) and Get ( LastErrorDetail ) can no longer return data for that error. All three must be captured in a single expression within one Set Variable step:
Set Variable [ $errData ; JSONSetElement ( "{}" ;
[ "lastError" ; Get ( LastError ) ; JSONNumber ] ;
[ "lastErrorDetail" ; Get ( LastErrorDetail ) ; JSONString ] ;
[ "lastErrorLocation" ; Get ( LastErrorLocation ) ; JSONString ]
) ]
When this pattern is used, Get ( LastErrorLocation ) returns "ScriptName\rStepName\rLineNumber" (carriage-return separated).
Never capture error data in separate steps — the first Set Variable clears the error for subsequent ones. See agent/docs/knowledge/error-data-capture.md for full details.
Additionally, Perform Script resets Get ( LastError ) to 0 when it successfully begins executing the subscript. The Agentic-fm Debug script's own error capture always sees lastError = 0. Callers must capture error data in the calling script and pass it as part of the JSON parameter.
Look up the target script's ID from CONTEXT.json or the scripts index:
grep "ScriptName" "agent/context/{solution}/scripts.index"
Read the human-readable source from agent/xml_parsed/scripts_sanitized/ to understand the logic. Identify where to insert debug capture points — typically immediately after steps that might fail or at decision points.
Generate a modified copy of the script as fmxmlsnippet XML in agent/sandbox/ that includes debug instrumentation at the identified points. Each debug point should:
$errData pattern above)Perform Script [ "Agentic-fm Debug" ] with the captured state as a JSON parameterExample debug instrumentation to insert after a risky step:
# Capture error data in ONE expression — Get(LastError) resets the error state
Set Variable [ $errData ; JSONSetElement ( "{}" ;
[ "lastError" ; Get ( LastError ) ; JSONNumber ] ;
[ "lastErrorDetail" ; Get ( LastErrorDetail ) ; JSONString ] ;
[ "lastErrorLocation" ; Get ( LastErrorLocation ) ; JSONString ]
) ]
Perform Script [ "Agentic-fm Debug" ; Parameter: JSONSetElement ( "{}" ;
[ "label" ; "after the risky step" ; JSONString ] ;
[ "vars" ; JSONSetElement ( "{}" ;
[ "errData" ; $errData ; JSONRaw ] ;
[ "myVar" ; $myVar ; JSONString ] ;
[ "otherVar" ; $otherVar ; JSONString ]
) ; JSONRaw ]
) ]
Validate the instrumented script with validate_snippet.py before proceeding.
The agent has the full deploy → run → read loop available:
POST {companion_url}/clipboard with the XMLPOST {companion_url}/trigger with a raw_applescript payload that:
POST {companion_url}/trigger with fm_app_name, script, and optionally target_fileagent/debug/output.json (allow 2–3 seconds for the script to execute and the companion to write the file)Prerequisites for Tier 3 autonomous debugging:
fmextscriptaccess extended privilege must be enabled on the active account's privilege set in the frontmost FM document (required for /trigger do script calls)companion_urlImportant: if deploying an instrumented copy of an existing script, use --replace mode (Cmd+A → Delete → Cmd+V) rather than creating a new script. After debugging, deploy the original script back to restore it.
Give the developer clear instructions:
To debug this, I need runtime variable state. Please do the following:
- The instrumented script is on your clipboard. Open "Script Name" in Script Workspace
- Cmd+A — select all existing steps and delete
- Cmd+V — paste the instrumented version
- Run the script as you normally would
- Let me know when it's done — I'll read
agent/debug/output.jsondirectly.
After debugging, provide the original script back on the clipboard for the developer to restore.
Read agent/debug/output.json:
cat agent/debug/output.json
The output contains:
vars — the variables and error data captured by the instrumented script. This is the authoritative diagnostic data. The errData object within vars contains lastError, lastErrorDetail, and lastErrorLocation as captured by the calling script.lastError/lastErrorLocation — captured by the debug script itself. Always 0/empty because Perform Script resets the error state. Ignore these for diagnosis.timestamp — when the debug script ranlabel — description of the debug pointParse the error data and identify the root cause. Explain the issue clearly and propose the fix.
If the solution does not have an Agentic-fm Debug script, the developer can add a temporary Set Variable step to collect debug state into a $$DEBUG global:
Set Variable [ $$DEBUG ; JSONSetElement ( "{}" ;
[ "errData" ; JSONSetElement ( "{}" ;
[ "lastError" ; Get ( LastError ) ; JSONNumber ] ;
[ "lastErrorDetail" ; Get ( LastErrorDetail ) ; JSONString ] ;
[ "lastErrorLocation" ; Get ( LastErrorLocation ) ; JSONString ]
) ; JSONRaw ] ;
[ "varName1" ; $varName1 ; JSONString ] ;
[ "varName2" ; $varName2 ; JSONString ]
) ]
The developer retrieves the value from the Data Viewer (Tools > Data Viewer) and pastes it into the conversation.
agent/docs/AGENTIC_DEBUG.md)development
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.