4d-form-layout
4D Form Layout
Use this skill to author 4D forms in a lossless intermediate JSON format, then convert that format back to native .4DForm.
Quick Start
- Start from a native form or a new layout JSON.
- Convert with
scripts/convert_4d_form.py. - Validate the layout and generated
.4DForm. - Validate the layout against the bundled schema.
python skills/4d-form-layout/scripts/convert_4d_form.py \
form-to-layout path/to/form.4DForm path/to/form.layout.json
python skills/4d-form-layout/scripts/convert_4d_form.py \
layout-to-form path/to/form.layout.json path/to/form.4DForm
python skills/4d-form-layout/scripts/convert_4d_form.py \
validate path/to/form.layout.json
python skills/4d-form-layout/scripts/convert_4d_form.py \
validate path/to/form.4DForm --all-rules
python skills/4d-form-layout/scripts/convert_4d_form.py \
validate path/to/form.layout.json --rule no_overlap --rule inside_bounds
Workflow
When converting an existing .4DForm:
- Keep root form metadata in
form. - Keep page order and object order exactly.
- Convert each object key in
pages[].objectsintoelements[].id. - Move positional keys into
layout.frame. - Infer
placementandalignheuristically when relations are obvious. - Preserve
layout.framefor every element so round-trip remains exact.
When authoring a new layout JSON:
- Model pages explicitly. Use page 0 as the shared page.
- If the form has one visible page, create an empty shared page 0 and put visible content on page 1.
- If the form uses tabs, keep shared chrome or shared buttons on page 0 and start tab content on page 1.
- Define
id,type,props, andlayoutfor each element. - Use
layout.placementfor positional relations such asbelow(input_email). - Use
layout.alignfor axis alignment. AcceptalignedWith(target.left)and shorthand such asleftortopwhen the placement target is the anchor. - Always provide
layout.frame.widthandlayout.frame.height. - Add
layout.frame.toporlayout.frame.leftonly when a relation does not determine that axis. - Use
references/design-rules.mdas a reference for spacing and alignment best practices.
Validation
Use these bundled sources while designing or reviewing a form:
- Schema:
references/formsSchema.json - Default property reference:
references/defaultJsonForm.json - Layout format reference:
references/layout-format.md - Graphical validation rules:
references/validation-rules.yaml
validate checks:
- the intermediate layout JSON shape
- semantic relation rules and anchor resolution
- the generated native
.4DFormagainstreferences/formsSchema.json - optional graphical rules against either a layout JSON input or a native
.4DForminput
Graphical validation is opt-in:
--rule rule_nameruns one or more named rules--all-rulesruns every rule inreferences/validation-rules.yaml--rules-file path/to/file.yamluses a custom4d-validationrule file
Current bundled graphical rules:
shared_page_requiredno_overlapconsistent_spacingalignment_consistencyinside_bounds
Notes
- Keep the intermediate file JSON-only in v1.
- Prefer editing the layout file, not absolute coordinates in
.4DForm. - Preserve unsupported properties verbatim in
props; do not redesign them. - Treat page 0 as the shared page when generating new forms.
- Treat relation targets as ordered dependencies: reference earlier elements on the same page.
- Graphical rules are heuristics. Use them selectively and ignore them per element when a form intentionally breaks a visual rule.
More from e-marchand/skills
4d-check-syntax
Check syntax and compile a 4D project to find errors and type issues. Use this skill when the user wants to compile, check syntax, or validate a 4D project. Creates a _compile method if not present, then runs it using tool4d. Returns compilation errors in JSON format for easy parsing.
114d-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.
6skill-creator
Guide for creating effective skills. This skill should be used when users want to create a new skill (or update an existing skill) that extends Claude's capabilities with specialized knowledge, workflows, or tool integrations.
54d-publish-gitlab
Publish a 4D project to GitLab using glab CLI. Use this skill when the user wants to publish, push, or share a 4D project to GitLab. Creates remote repository, initializes git, and pushes code. Supports gitlab.com and private/self-hosted GitLab instances with group/namespace support.
1