New to Claude Skills? Learn how to install them →

earthtojake on GitHub

SDF Generation

Free

Efficiently generate and validate SDFormat documents.

Get this skill

Free · Opens the source repo

What SDF Generation does

The SDF Generation skill is designed for developers and designers working with SDFormat (SDF) files, which are essential for describing simulator and world behavior in robotics and simulation environments. This skill allows users to generate .sdf files from Python sources using the gen_sdf() function, facilitating the creation of models, worlds, links, joints, and other components necessary for simulation. The skill emphasizes the importance of maintaining a clear workflow and adhering to established standards, ensuring that generated outputs are consistent and reliable.

When using this skill, it is crucial to treat the Python file defining the gen_sdf() as the source of truth, while the configured .sdf files are considered generated artifacts. The skill provides a structured approach to identifying the target consumer, whether it be a specific simulator like Gazebo or visualization tools, and allows for the generation of model-level or world-level SDF documents. Users are guided to follow best practices, such as using SI units and preferring version 1.12 for new outputs, which helps maintain compatibility across different environments.

Additionally, the skill includes a robust validation process, encouraging users to run checks after generation to ensure that the output meets the necessary requirements for the target simulator. This includes bundled validation checks and optional checks with the gz sdf --check command, which adds an extra layer of assurance before deployment. The skill also highlights the importance of documentation and reporting, requiring users to provide clear reports on the checks run and any assumptions made during the generation process.

Overall, the SDF Generation skill is an invaluable tool for those involved in robotics and simulation, streamlining the process of creating and validating SDFormat files while ensuring adherence to best practices and standards.

When to use it

Use this skill when you need to generate or validate SDFormat documents for robotics simulations or when working with the `gen_sdf()` Python source.

When not to use it

Avoid using this skill for tasks related to signed-distance-field geometry or raw geometry generation, as it is specifically tailored for SDFormat outputs.

What you can build with it

Generating a Model SDF

You need to create a reusable robot model in SDFormat for a simulation environment. Use this skill to generate the model-level SDF file from your Python source.

Validating an SDF Document

After generating an SDF file, run validation checks to ensure it meets the requirements of your target simulator, such as Gazebo.

Creating World-Level SDF

You are tasked with creating a world-level SDF file that includes multiple models and their interactions. This skill helps structure and generate that document efficiently.

How to install SDF Generation

View source

1. Install with the skills CLI

npx skills add earthtojake/text-to-cad/sdf --agent claude-code

2. Or install it manually

Download the skill folder and drop it into ~/.claude/skills/ for all projects, or .claude/skills/ to scope it to one repo. Restart Claude Code so it picks up the new skill.

Anthropic's agentic coding CLI, and the reference implementation of Agent Skills. Drop a skill folder into ~/.claude/skills and Claude Code loads it automatically whenever a task matches the skill's description. Claude Code docs

Inside SKILL.md

Written by earthtojake

SDF

Provenance: maintained in earthtojake/text-to-cad. Use the installed local skill files as the runtime source of truth; the repository link is only for provenance and release review.

Use this skill when the deliverable is an SDFormat document or a Python gen_sdf() source. SDFormat describes simulator and world behavior: models, worlds, frames, poses, links, joints, inertials, visuals, collisions, sensors, lights, physics, plugins, includes, and simulator metadata.

This skill is for SDFormat, not signed-distance-field geometry.

Core rules

  1. Treat the Python file defining gen_sdf() as source of truth. Treat configured .sdf files as generated artifacts unless the user explicitly asks for direct XML editing.
  2. Identify the target consumer before editing: Gazebo/libsdformat version, another simulator, visualization-only tooling, model package, or world handoff.
  3. Decide document kind: model-level SDF, world-level SDF, or model-in-world. Prefer model-level SDF for reusable robot/object exports.
  4. Use SI units unless the target explicitly requires otherwise: meters, kilograms, seconds, radians.
  5. Prefer version="1.12" for new outputs unless the target consumer constrains the version.
  6. Establish the design ledger before writing poses, frames, joint axes, mesh scales, inertials, sensors, or plugins. Use references/design-ledger.md and references/llm-guardrails.md.
  7. Do not infer spatial transforms from visual impression alone. Derive poses, axes, scale, mass, inertia, and frame names from upstream source data, drawings, simulator documentation, measured values, or explicit assumptions.
  8. Prefer helper functions and named constants over large XML string literals. Hidden numbers are a common SDF failure mode.
  9. Generate only explicit targets with scripts/sdf or the repository's existing SDF launcher. Do not run directory-wide generation.
  10. Regenerate upstream geometry, mesh, robot-description, render, topology, or package assets with their owning workflows before regenerating SDF that references them.
  11. After generation, run available checks: bundled validation, optional gz sdf --check, simulator load, joint motion, and plugin/sensor startup.
  12. Report assumptions, skipped checks, unresolved resource paths, and target-specific compatibility risks.

Scope

Use this skill for SDFormat outputs and generators. Do not use it for signed-distance-field modeling, raw geometry generation, planning semantics, or to paper over incorrect upstream robot/source data unless the task is explicitly simulator-only.

CAD Viewer Handoff

After completing SDF work that creates or modifies a .sdf, you must ALWAYS hand the explicit file path to $cad-viewer when that skill is installed. $cad-viewer must start CAD Viewer if it is not already running and return link(s) to the relevant created or updated file(s); if $cad-viewer is unavailable or startup fails, report that instead of silently omitting the handoff.

Workflow

  1. Locate the gen_sdf() source and intended .sdf output.
  2. Read or create the design ledger.
  3. Read references/frame-semantics.md before editing any <pose>, <frame>, joint axis, relative_to, expressed_in, nested scope, sensor frame, or plugin frame.
  4. Edit the generator source, not generated XML.
  5. Use optional builder helpers when they make the generated structure clearer; raw ElementTree is still allowed.
  6. Regenerate the explicit target.
  7. Treat bundled validation as a guardrail, not simulator proof.
  8. Run target-consumer smoke tests when available.
  9. Report checks run, checks skipped, and assumptions. Static rendering does not execute SDF plugins or read file-authored motion metadata.

Commands

Run with the project or workspace Python environment. Treat python in examples as an interpreter placeholder; if bare python is unavailable, substitute python3, a project virtualenv interpreter, or the configured interpreter path.

python scripts/sdf path/to/source.py
python scripts/sdf path/to/source.py -o path/to/output.sdf
python scripts/sdf path/to/a.py=out/a.sdf path/to/b.py=out/b.sdf

Plain Python targets write sibling .sdf files beside their sources. -o / --output is valid only with one plain target. SOURCE.py=OUTPUT.sdf supports custom multi-target destinations.

If the runtime supports optional external checking:

python scripts/sdf path/to/source.py --gz-check auto
python scripts/sdf path/to/source.py --gz-check required
python scripts/sdf path/to/source.py --gz-check never

gz sdf --check is optional target-consumer validation. It should be reported as skipped when unavailable unless explicitly required.

Required report shape

When finishing an SDF task, include a compact report:

Generated: path/to/model.sdf from path/to/model.py
Checks run:
- bundled SDF validation: passed
- gz sdf --check: skipped, gz not installed
- simulator load: skipped, target simulator unavailable
- viewer handoff: `$cad-viewer` link returned
Assumptions:
- Assumed mesh units are meters.
- Assumed lidar frame is coincident with lidar_link.
Risks:
- Camera plugin filename was not verified in the target simulator environment.

References

  • Generation command: references/gen-sdf.md
  • Generator contract: references/generator-contract.md
  • SDF workflow: references/sdf-workflow.md
  • Builder helpers: references/builder-helpers.md
  • LLM guardrails: references/llm-guardrails.md
  • Design ledger: references/design-ledger.md
  • Frame semantics: references/frame-semantics.md
  • Validation scope: references/validation.md
  • Smoke tests: references/smoke-tests.md
  • Interoperability notes: references/interoperability.md
  • Examples: references/examples.md
  • Runtime notes and current limitations: references/implementation-notes.md

Frequently asked questions about SDF Generation

Similar skills