New to Claude Skills? Learn how to install them →

Gearthtojake on GitHub

G-code Generator

Free

Efficiently convert 3D models to G-code for 3D printing.

Get this skill

Free · Opens the source repo

What G-code Generator does

The G-code Generator skill provides a streamlined workflow for converting 3D mesh files into printer-ready G-code. It supports a variety of mesh formats, including .stl, .obj, .3mf, .ply, .glb, and .gltf, allowing users to work with different types of 3D models. This skill is particularly useful for developers and designers who need to prepare models for 3D printing without having to manually configure slicer settings or profiles.

The skill operates by leveraging local slicer command-line interfaces (CLIs) to generate G-code. Users must provide a printer profile in JSON format, which outlines the specific settings required for the printer being used. The G-code Generator skill does not upload or manage print jobs, ensuring that all operations remain local and secure. It also includes features for inspecting mesh files to confirm their suitability for slicing and validating the generated G-code to prevent errors before printing.

To use the skill, users can execute commands to discover available slicer backends, inspect mesh files, perform dry-runs of slicing commands, and finally execute the slicing process. The validation step checks for critical parameters in the G-code, such as temperature commands and movement instructions, ensuring that the generated output is safe for use with 3D printers.

This skill is ideal for anyone involved in 3D printing, including engineers, designers, and hobbyists who require a reliable method for preparing their models for printing. By automating the slicing process and validating the output, users can save time and reduce the risk of print failures.

When to use it

Use this skill when you need to convert 3D mesh files into G-code for printing, especially when working with various file formats.

When not to use it

This skill is not suitable for users who require Bambu-specific G-code formats or those who need to directly manage print jobs from the software.

What you can build with it

Converting STL Files

Use the skill to convert your `.stl` files into G-code ready for printing, ensuring compatibility with your printer.

Validating G-code Before Printing

Validate the generated G-code to check for errors and ensure safe printing parameters before handing it off to your printer.

Inspecting Mesh Files

Inspect your 3D mesh files to confirm they are slice-ready, avoiding potential issues during the slicing process.

How to install G-code Generator

View source

1. Install with the skills CLI

npx skills add earthtojake/text-to-cad/gcode --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

G-code

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 for plain .gcode generation from mesh files. It is printer-agnostic and never uploads, starts, or packages print jobs.

Workflow

  1. Confirm the input is a supported mesh: .stl, .obj, unsliced .3mf, .ply, .glb, or .gltf.
  2. Require an explicit printer/profile wrapper JSON. Do not invent real-printer profiles.
  3. Discover slicer backends when the backend is unknown:
python scripts/gcode_tool.py discover
  1. Inspect the input:
python scripts/gcode_tool.py inspect --input path/to/model.stl --json
  1. Dry-run the slicer command before executing:
python scripts/gcode_tool.py slice \
  --input path/to/model.stl \
  --output /tmp/model.gcode \
  --profile path/to/profile.json \
  --backend auto \
  --dry-run
  1. Execute only after the dry-run command and profile are appropriate:
python scripts/gcode_tool.py slice \
  --input path/to/model.stl \
  --output /tmp/model.gcode \
  --profile path/to/profile.json \
  --backend auto \
  --execute
  1. Validate the generated G-code:
python scripts/gcode_tool.py validate \
  --gcode /tmp/model.gcode \
  --profile path/to/profile.json \
  --json

CAD Viewer Handoff

After completing G-code work that creates or modifies a plain .gcode, 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); the preview is diagnostic only and does not replace this skill's static validation. If $cad-viewer is unavailable or startup fails, report that instead of silently omitting the handoff.

Profile Contract

Every slice requires a wrapper profile JSON with an absolute native slicer profile path:

{
  "backend": "orcaslicer",
  "native_config": "/absolute/path/to/native-slicer-profile",
  "machine": {
    "name": "Example Printer",
    "bed_size_mm": [180, 180],
    "z_height_mm": 180,
    "motion_bounds_mm": {
      "x": [0, 180],
      "y": [0, 180],
      "z": [0, 180]
    }
  },
  "filament": {
    "type": "PLA",
    "nozzle_temp_c": 220,
    "bed_temp_c": 65
  }
}

The wrapper supplies validation bounds and backend selection. machine.motion_bounds_mm is optional; omit it for the default 0..bed_size and 0..z_height bounds, or set it from a native printer profile when start/end G-code intentionally uses safe wipe/purge positions outside the printable area. The native slicer profile remains the source of detailed process, printer, and filament behavior.

For OrcaSlicer, use native_settings and native_filaments when the real profile is split across machine, process, and filament JSON files. Keep native_config as an absolute path to the primary native profile for compatibility:

{
  "backend": "orcaslicer",
  "native_config": "/absolute/path/to/machine-or-process.json",
  "native_settings": [
    "/absolute/path/to/machine.json",
    "/absolute/path/to/process.json"
  ],
  "native_filaments": [
    "/absolute/path/to/filament.json"
  ],
  "machine": {
    "name": "Example Printer",
    "bed_size_mm": [180, 180],
    "z_height_mm": 180
  },
  "filament": {
    "type": "PLA",
    "nozzle_temp_c": 220,
    "bed_temp_c": 65
  }
}

Backends And Inputs

Preferred slicer backend order is orcaslicer, prusa-slicer, then curaengine. Prefer installing OrcaSlicer when no preferred backend is available; on macOS use brew install --cask orcaslicer and then rerun discover. The helper checks both PATH and the usual /Applications/OrcaSlicer.app cask location. Bambu Studio may be reported by discovery as available but is not preferred because its CLI export path has shown macOS instability.

Pass .stl, .obj, and unsliced .3mf directly to the slicer. Convert .ply, .glb, and .gltf to temporary STL at execution time with optional trimesh; if trimesh is unavailable, ask the user to install it or provide .stl, .obj, or unsliced .3mf.

Reject .step, .stp, .dxf, .svg, .urdf, and .sdf in v1. inspect and slice fail with a structured remediation object naming the skill and command that produce a sliceable mesh; use it instead of inferring a conversion workflow:

  • .step, .stp: boundary-representation CAD, not a mesh. Export an STL sidecar with $cad (python scripts/step --kind part <input> --stl <output>.stl, or target the generator with python scripts/step <model>.step.py --stl <output>.stl), then slice the exported .stl here.
  • .dxf, .svg: 2D drawings with no 2D-to-mesh conversion in this toolchain. Model the 3D solid in $cad with gen_step() and export an STL sidecar, then slice that. If the part is a flat cut rather than a print, use $sendcutsend instead of this skill.
  • .urdf, .sdf: robot descriptions that reference per-link mesh files. Slice the referenced .stl/.obj meshes one at a time; regenerate stale or missing ones from the owning CAD source with $cad first. Use $urdf or $sdf for the robot description itself.

Read references/slicer-backends.md when backend behavior, profile expectations, or source links matter.

Validation

Always validate generated G-code before handing it to printer-specific workflows. The validator checks for non-empty content, temperature commands, movement commands, extrusion moves, XYZ bounds, and unknown command warnings.

Read references/gcode-validation.md when interpreting validation output or deciding whether a warning is acceptable.

Bambu Boundary

This skill generates plain .gcode only. It does not create Bambu .gcode.3mf archives and does not contact printers. For Bambu upload/start workflows, hand off the validated plain .gcode to $bambu-labs. Let $bambu-labs choose the printer-specific LAN handoff, such as an A1 Mini template project or an explicitly enabled bambox project package.

Frequently asked questions about G-code Generator

Similar skills