Run a 4D project method with the right runtime.
tool4d for most test-like runs, especially when --dataless is acceptable.tool4d first. If that run fails for reasons that look specific to tool4d or missing database/runtime support, then switch to the full 4D runtime.tool4d, or the user explicitly says tool4d is insufficient.4D.app, the inner 4D binary, or 4D.exe.Prefer this fallback strategy because it is usually faster than deciding up front from incomplete context.
tool4d can be located in two ways:
Set TOOL4D to the tool4d executable:
export TOOL4D="/path/to/tool4d.app/Contents/MacOS/tool4d"
tool4d is typically installed by the 4D-Analyzer extension in one of these locations:
$HOME/Library/Application Support/Code/User/globalStorage/4d.4d-analyzer/tool4d/$HOME/Library/Application Support/Antigravity/User/globalStorage/4d.4d-analyzer/tool4d/Use scripts/find_tool4d.py to return the newest installed executable.
python3 <skill-dir>/scripts/find_tool4d.py
The script checks:
TOOL4D%APPDATA% and %LOCALAPPDATA%"<tool4d_path>" --project="<project_path>" --startup-method="<method_name>" --skip-onstartup --dataless
Parameters:
--project: Full path to the .4DProject file--startup-method: Method name without .4dm--skip-onstartup: Skip the database On Startup--dataless: Run without a data fileExample:
SKILL_DIR="/path/to/4d-run"
TOOL4D="$(python3 "$SKILL_DIR/scripts/find_tool4d.py")"
"$TOOL4D" --project="/path/to/MyProject/MyProject.4DProject" --startup-method="test_MyFeature" --skip-onstartup --dataless
Ask the user for the 4D executable path first:
/Applications/4D.app/Applications/4D.app/Contents/MacOS/4DC:\Program Files\4D\4D.exeThen run the helper:
SKILL_DIR="/path/to/4d-run"
python3 "$SKILL_DIR/scripts/run_with_4d.py" \
"/Applications/4D.app" \
"/path/to/MyProject/MyProject.4DProject" \
"test_UsesDatabase"
run_with_4d.py launches the runtime, waits for it to exit, and kills it after 30 seconds by default if it is still running.
Important:
QUIT 4D when the work is complete.QUIT 4D, the helper script will terminate the process after FOURD_KILL_AFTER seconds.FOURD_KILL_AFTER=0 only when you intentionally want to leave 4D running.Equivalent direct command if you already know the binary path:
"C:\Program Files\4D\4D.exe" \
--project="/path/to/MyProject/MyProject.4DProject" \
--startup-method="test_UsesDatabase" \
--skip-onstartup
tool4d sends most diagnostic output to stderr.QUIT 4D.ALERT is not reliable for automated runs. Prefer LOG EVENT or file output.When deciding whether to fall back from tool4d to full 4D, treat these as fallback signals:
tool4d run fails and the failure points to forbidden methods, unavailable runtime features, UI dependencies, or missing access to the real data file.tool4d run cannot complete the startup method even though the method name and project path are correct.Do not fall back automatically for ordinary method bugs. If the method itself is wrong, report the failure instead of switching runtimes.
Use LOG EVENT to output messages:
LOG EVENT(Into system standard outputs; "message"; Information message)
Or write to a file:
File("/path/to/debug.txt").setText($debugText)
.4DProject file.tool4d is clearly sufficient, clearly insufficient, or unclear.tool4d first because that is usually the fastest path.tool4d succeeds, keep using it.tool4d fails for a likely runtime/database limitation, ask the user for the 4D executable path and retry with full 4D.QUIT 4D or use scripts/run_with_4d.py so the process gets cleaned up.