SendCutSend Skill Validation: How Text-to-CAD Validates G-Code Before Upload
The SendCutSend skill performs a six-stage validation pipeline—checking skill manifest integrity, G-code syntax, file size limits, printer compatibility, dry-run simulation, and safety commands—before allowing upload to CNC or 3D printing hardware.
The SendCutSend skill in the earthtojake/text-to-cad repository ensures only safe, compatible G-code reaches your fabrication device. This validation suite, implemented in the cadgen CLI and defined in skills/sendcutsend/scripts/sendcutsend.py, parses job files through multiple checkpoints to prevent malformed or unsafe commands from executing on physical hardware.
Skill Manifest Verification
The validation process begins by parsing skills/sendcutsend/SKILL.md to confirm required metadata fields are present. The CLI checks that the skill declares its name, description, and required file paths before initializing the validation workflow. This structural check ensures the skill package itself is complete, as verified by the test suite in tests/python/skills/sendcutsend/test_skill_structure.py.
G-Code Syntax Verification
The core validation uses the internal cadgen G-code parser to analyze the supplied .gcode file. According to the implementation in skills/sendcutsend/scripts/sendcutsend.py, the parser performs:
- Line ending validation: Ensures proper
\nor\r\ntermination sequences - Command token verification: Validates standard G-code commands such as
G0,G1, andM104 - Numeric bounds checking: Confirms extrusion limits and temperature ranges fall within printer-specific boundaries defined in the hardware profile
File Size and Encoding Constraints
Before transmission, the skill enforces payload constraints defined in tests/python/global/test_cli_payload_budget.py. The validation rejects files that exceed the CLI payload budget or contain non-UTF-8 characters, preventing buffer overflows and encoding errors during the upload process.
Printer Compatibility Validation
The skill reads the target printer.json configuration to verify hardware compatibility. It confirms that the G-code's extruder count, bed dimensions, and supported commands match the capabilities of the specified printer model passed via the --printer flag.
Dry-Run Simulation Mode
When invoked with --dry-run, the skill executes a simulation that parses the entire G-code sequence without opening the serial port. This validation catches runtime errors such as missing tool-change commands or undefined coordinate systems before physical connection attempts, allowing developers to verify jobs offline.
Safety Command Screening
The validation layer screens for potentially dangerous commands such as M112 (emergency stop). If detected, the skill aborts transmission unless the user explicitly provides the --force flag, protecting against accidental hardware locks or unsafe operational states.
Code Examples
Run a standard upload with full validation:
cadgen send --printer my-prusa --gcode prints/part.gcode
Validate the file without transmitting to hardware:
cadgen send --printer my-prusa --gcode prints/part.gcode --dry-run
Force upload despite safety warnings (use with caution):
cadgen send --printer my-prusa --gcode prints/part.gcode --force
Summary
- The SendCutSend skill validates G-code through six specific stages before upload
- Manifest validation ensures
SKILL.mdcontains required metadata fields - Syntax verification checks line endings, command tokens, and numeric argument bounds
- File size constraints prevent payload budget violations as defined in the global test suite
- Printer compatibility confirms hardware capabilities match G-code requirements
- Dry-run mode allows complete validation without hardware connection
- Safety checks block emergency commands unless explicitly overridden
Frequently Asked Questions
What files does the SendCutSend skill validate against?
The skill validates against skills/sendcutsend/SKILL.md for manifest integrity, the user-provided .gcode file for syntax compliance, and printer.json for hardware compatibility. It also references tests/python/global/test_cli_payload_budget.py to enforce size limits and encoding standards.
How do I run validation without actually sending the G-code?
Use the --dry-run flag with the cadgen send command. This executes the parser and simulation stages—including all syntax, compatibility, and safety checks—without opening the serial port or transmitting data to the physical printer.
What happens if the G-code contains an emergency stop command?
The validation detects safety-critical commands like M112 and aborts the upload process immediately. To proceed despite these warnings, you must include the --force flag, though this bypass is not recommended for production workflows.
Where is the validation logic implemented?
The primary validation logic resides in skills/sendcutsend/scripts/sendcutsend.py, with test coverage provided by tests/python/skills/sendcutsend/test_skill_structure.py and tests/python/skills/sendcutsend/test_report_template.py ensuring the validation pipeline generates correct status reports and handles edge cases properly.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →