4d-check-syntax
4D Syntax Checker
Compile a 4D project to check for syntax errors and type mismatches.
Prerequisites
Uses the 4d-run skill to execute the compilation method. Ensure tool4d is available:
- Install 4D-Analyzer extension in VS Code/Antigravity, OR
- Set
TOOL4Denvironment variable to point to tool4d executable
The _compile Method
Compilation requires a _compile method in the project. If not present, copy assets/_compile.4dm to Project/Sources/Methods/_compile.4dm.
Compilation Output
Success
{"success":true,"errors":[]}
Errors
{
"success": false,
"errors": [
{
"message": "Syntax error",
"isError": true,
"code": {
"type": "classFunction",
"className": "MyClass",
"functionName": "myMethod",
"path": "[class]/MyClass/myMethod",
"file": "[object File]"
},
"line": 10,
"lineInFile": 42
}
]
}
Error Properties
message: Error descriptionisError: true for errors, false for warningscode.type: "projectMethod", "classFunction", etc.code.className: Class name (for class methods)code.functionName: Function nameline: Line within the functionlineInFile: Absolute line in the file
Workflow
- Check for _compile method: Look in
Project/Sources/Methods/_compile.4dm - Create if missing: Write the _compile method using the template above
- Find tool4d: Use 4d-run skill to locate tool4d
- Run compilation: Execute
_compilemethod with--dataless - Parse results: Extract JSON from ALERT output
Running Compilation
"<tool4d_path>" --project="<project_path>" --startup-method=_compile --dataless 2>&1
Output format:
{"success":true,"errors":[]}
The JSON is output directly to system standard output via LOG EVENT.
Common Compilation Errors
| Error | Cause | Fix |
|---|---|---|
| "Syntax error" | Invalid 4D syntax | Check line for typos |
| "Object syntax is not valid" | Invalid object property access | Use [index] for 4D.Blob properties |
| "Cannot make an assignment with those types" | Type mismatch | Check variable types |
| "Undeclared property 'X' used" | Missing property declaration | Add property X : Type to class |
| "The variable $X has not been explicitly declared" | Missing var declaration | Add var $X : Type |
| "signed integer overflow handling differs" | PCH cache issue | Not a code error, can ignore |
Integration Example
# Find tool4d
TOOL4D=$(python3 ".claude/skills/4d-run/scripts/find_tool4d.py")
# Run compilation and parse JSON result
OUTPUT=$("$TOOL4D" --project="/path/to/Project/MyProject.4DProject" --startup-method=_compile --dataless 2>&1)
# The JSON is output directly via LOG EVENT
echo "$OUTPUT" | jq .
More from e-marchand/skills
4d-run
Run a 4D project method. Use tool4d by default for fast dataless execution, and fall back to a user-provided 4D executable path when the method needs a real database or runtime features unavailable in tool4d. Includes Python helpers for macOS and Windows.
94d-find-command
Find 4D commands by keyword. Use this skill when the user wants to search for, find, or discover 4D commands matching a term. Searches the gram.4dsyntax file from tool4d.app to list matching command names and uses bundled syntax metadata for readable signatures and summaries. Filters out deprecated commands.
94d-clean-project
Clean a 4D project by removing generated files, caches, and system artifacts.
64d-add-dependency
Add dependencies to a 4D project. Use when the user wants to add a component, library, or dependency to their 4D project. Supports GitHub repos (owner/repo format), GitHub URLs (with automatic tag extraction from release URLs), and local folder paths. Handles dependencies.json and environment4d.json configuration.
64d-create-project
Create a new 4D project from scratch. Use this skill when the user wants to initialize, create, or start a new 4D project. Creates the required folder structure and .4DProject configuration file.
64d-doc-lookup
Look up 4D documentation for commands, classes, or language concepts. Use when the user asks about a 4D command's syntax, parameters, or usage, needs class API reference, or wants to understand a 4D language concept. Resolves names to developer.4d.com URLs and optionally fetches page content.
5