marlin-bed-leveling
Lets your agent calibrate bed leveling on 3D printers with Marlin firmware. It adjusts the printer to ensure the first print layer is perfect.
What it does
This tool helps set up the bed leveling on 3D printers using Marlin firmware. It ensures the first layer of your print adheres perfectly, even if the print bed isn't perfectly flat.
When to use it
- ✓When the first layer of your 3D print doesn't stick well to the bed.
- ✓If your 3D printer doesn't seem to 'turn on' bed leveling after it 'homes' itself.
- ✓To fine-tune the exact distance between the print nozzle and the sensor that measures the bed.
Example of what to ask your AI
“How do I set up automatic bed leveling on my Marlin printer?”
Want more? Open the sections below.
How to use
The easiest way: copy the message below and paste it into Claude, ChatGPT, Cursor or any AI. It reads the skill and follows the instructions.
Skill link
Ready-to-paste message
How it works
It adjusts the settings in the printer's software (Marlin) so it knows the exact height at various points on the bed. This is done by sending specific commands that measure the bed and save this information.
Installation
Easiest way: copy the skill link and paste it into Claude, ChatGPT or Cursor asking it to follow the instructions.
In the terminal (Claude Code, Codex, Cursor), in your project folder:
npx skills add sickn33/agentic-awesome-skills --skill marlin-bed-levelingOr download just the file:
curl -L https://raw.githubusercontent.com/sickn33/agentic-awesome-skills/main/plugins/agentic-awesome-skills-claude/skills/marlin-bed-leveling/SKILL.md -o SKILL.mdTechnical content (original SKILL.md)
Original text by the author, straight from GitHub.
Marlin Bed Leveling: Deterministic Calibration & First-Layer Mesh Engineering
Master Marlin 2.x bed leveling architectures (Unified Bed Leveling UBL, Bilinear ABL, Manual Mesh MBL) to guarantee flawless first-layer adhesion through rigorous G-code phase workflows, probe offset math, and persistent EEPROM compensation.
When to Use This Skill
Activate this skill when:
- Calibrating, tuning, or troubleshooting automatic bed leveling on Marlin 2.x 3D printers (Ender 3, CR-10, Prusa clones, custom CoreXY / Cartesian machines).
- The user asks: "How do I set up UBL in Marlin?", "My printer homes with G28 and ignores the mesh", "Calculate BLTouch Z-probe offset", "Generate G26 validation print G-code", or "Edit warped mesh points with M421".
- Diagnosing first-layer defects: nozzle dragging across PEI sheets, corner detachment, uneven squish, or compensation disabling after homing.
- Sizing slicer start G-code sequences (Cura, PrusaSlicer, OrcaSlicer, Bambu Studio) with thermal soaking and mesh restoration.
Do NOT use this skill when:
- Calibrating Klipper or RepRapFirmware printers (different firmware syntax and mesh compensation systems).
- Fixing gross mechanical skew: loose V-slot rollers, bent Z leadscrews, or wobbly gantry arms (hardware faults cannot be solved by software leveling).
- Delta printer kinematics setup requiring radius and tower endstop adjustments before mesh probing.
Core Mental Models & Non-Negotiable Rules
The Post-Homing Enable Mandate (
G28Disables Leveling):- In Marlin firmware, executing
G28(Home All Axes) automatically DISABLES bed leveling compensation by default (RESTORE_LEVELING_AFTER_G28is often disabled in vendor firmware). - In every print start G-code, the leveling restoration command MUST be issued strictly AFTER
G28:G28 ; Home all axes (silently turns leveling OFF) M420 S1 ; Re-enable bed leveling compensation from EEPROM mesh - Failing to include
M420 S1(orG29 Afor UBL) afterG28causes the printer to execute the entire print with zero leveling compensation.
- In Marlin firmware, executing
The 5-Phase UBL Calibration Loop: Unified Bed Leveling (UBL) is a state machine requiring five sequential phases:
- Phase 1 (Probe Reachable Grid):
G29 P1probes all coordinates physically reachable by the probe offset. - Phase 2 (Manual Edge Probing):
G29 P2uses a paper feeler gauge for points the BLTouch cannot reach due to gantry geometry. - Phase 3 (Mathematical Extrapolation):
G29 P3 T0.0fills unprobed edge coordinates by extrapolating slopes from adjacent measured points. - Phase 4 (Validation & Micro-Tuning):
G26 B60 H210 F1.75prints a single-layer validation test pattern; inspect and edit coordinates withM421 I... J... Q.... - Phase 5 (Storage & Activation):
G29 S1saves to EEPROM mesh slot 1;G29 Aactivates UBL;M500commits to permanent EEPROM storage.
- Phase 1 (Probe Reachable Grid):
Thermal Equilibrium Pre-Flight Invariant:
- Aluminum build plates, magnetic stickers, and spring-steel PEI sheets expand and warp non-linearly under thermal expansion.
- Probing a bed at room temperature (20°C) and then printing at 60°C or 100°C bakes a $0.08\text{--}0.20\text{mm}$ error into every mesh point.
- Mandatory Pre-Flight: Beds MUST be heated to target operating temperature and soaked for $\ge 5\text{ minutes}$ prior to running
G29probing.
Z-Probe Offset Sign Convention (
M851 Z...):- For downward-deploying probes (BLTouch, CRTouch, inductive sensors) where the probe trigger point triggers below the nozzle tip: $$\mathbf{Z\text{-}Offset\ is\ strictly\ NEGATIVE}\ (e.g.,\ \text{M851 Z-1.85})$$
- A positive Z-offset on a downward-deploying probe instructs the firmware that the nozzle is lower than the probe trigger, driving the nozzle directly into the bed on the first move.
- Adjusting Z-offset with paper gauge:
- More resistance / tighter squish $\implies$ more negative (e.g.,
-1.80$\to$-1.85). - Less resistance / looser gap $\implies$ less negative (e.g.,
-1.80$\to$-1.75).
- More resistance / tighter squish $\implies$ more negative (e.g.,
Mesh Fade Height Geometry (
M420 Z...):- Leveling compensation must gradually fade out as Z-height increases so top surface layers print geometrically flat rather than conforming to the bed warp.
…
FAQ
Why does bed leveling stop working after the printer homes?
The command that 'homes' the printer (G28) turns off leveling by default. You need to send it again (with M420 S1) afterward to re-enable it.
Do I need to heat the bed before leveling?
Yes, it's very important to heat the bed to your printing temperature and wait a few minutes. Metal expands when heated, which changes the bed's shape.
What is the Z-probe offset?
It's the exact distance between the tip of the print nozzle and the point where the leveling sensor (probe) touches the bed. A negative value is typically used for sensors like the BLTouch.
Details
Original description by the author
Calibrates Marlin 2.x 3D printer firmware bed leveling: Unified Bed Leveling (UBL), Bilinear ABL, M420 S1 post-homing, Z-probe offsets, G26 mesh prints, and EEPROM slots. Trigger phrases: marlin bed leveling, ubl calibration, m420 s1, z probe offset, g29 bed level, first layer adhesion.
Popularity
- GitHub stars
- 48k
- Ranking position
- #3564
- License
- MIT
- Updated
- 10/15/2026
Comments
- …
More skills from this repository
00-andruia-consultant
Helps your agent start or improve AI projects. It analyzes code, suggests tools, and creates action plans in Spanish.
sickn33/agentic-awesome-skills
007
Lets your agent perform security audits and threat modeling. It's useful for protecting projects against attacks and vulnerabilities.
sickn33/agentic-awesome-skills
10-andruia-skill-smith
Helps your agent create or improve AI tools. It defines how tools work, writes documentation, and validates the structure.
sickn33/agentic-awesome-skills
20-andruia-niche-intelligence
Lets your agent create a summary about a specific industry. It's useful for understanding the context, rules, usage patterns, and risks of a project, using reliable sources.
sickn33/agentic-awesome-skills
Similar skills
dashboard-builder
Helps your agent create useful monitoring dashboards. It turns data into charts that answer important system questions.
affaan-m/ECC
dev-team
Simulates a collaborative development team where different roles respond to a problem together. It's useful for getting multiple perspectives without manually switching agents.
affaan-m/ECC
ecc-council
Has your agent convene a four-voice council for difficult decisions. It's useful when there are multiple good options and debate is needed before choosing.
affaan-m/ECC