# Skill: Agentic 3D Printing & Physical AI Micro-Manufacturing

> **URI**: `https://drewsky.ai/skills/3d-printing-micro-manufacturing.md`  
> **Type**: Machine-Executable Agent Directive & Operational SOP  
> **Version**: 1.0.0  
> **Status**: Verified Operational  

---

## 1. Executive Mission

Transform desktop 3D printers into an **autonomous micro-manufacturing and rapid-prototyping engine** managed by AI agents.

By coupling LLMs and local vision models with slicing APIs (PrusaSlicer / Cura / OrcaSlicer CLI) and printer controllers (Klipper / Moonraker / OctoPrint REST APIs), an agent can take an idea or functional requirement, generate or retrieve CAD parameters (OpenSCAD / CadQuery), slice with deterministic profiles, dispatch print jobs, and monitor execution.

---

## 2. The Sovereign Hardware-to-Revenue Architecture

```mermaid
graph TD
    A[Customer Need / Trending Market Signal] --> B[Agent: Parametric CAD Engine - OpenSCAD / CadQuery]
    B --> C[Agent: CLI Slicing - OrcaSlicer / PrusaSlicer Headless]
    C --> D[Moonraker / Klipper REST API: Push G-code]
    D --> E[Physical 3D Printer Farm: Active Print]
    E --> F[Vision Feedback: Bed Adhesion / Spaghetti Detection]
    F -->|Failure| G[Agent: Emergency Stop & Parameter Correction]
    F -->|Success| H[Physical Assembly / Drop-Ship Fulfillment]
```

---

## 3. High-Margin Micro-Manufacturing Product Vectors

Avoid low-margin plastic trinkets. Focus on functional, customized, high-perceived-value items:
1. **Developer & Battlestation Ergonomics**:
   - Custom Mac Studio / Mini mount brackets with integrated cable routing.
   - Modular Gridfinity organizers tailored for mechanical keyboard modders and solder stations.
2. **AI & Robotics Edge Enclosures**:
   - Custom active-cooling cases for NVIDIA Jetson, Raspberry Pi 5 clusters, and Coral TPUs.
   - DIN-rail smart home sensor modules.
3. **On-Demand Local Replacement Parts**:
   - Obsolete appliance gears, EV charging cable holsters, specialized camera rigs.
4. **Hybrid Physical-Digital Dropshipping**:
   - Customers order customized designs through a web portal; agent automatically generates the CAD variant, slices it, queues it on the print farm, and generates shipping labels via EasyPost/Shippo.

---

## 4. Operational Pipeline for AI Agents

### Step 1: Parametric CAD Generation via OpenSCAD
Agents should not output raw, uneditable STL meshes. Instead, agents output clean, mathematical **OpenSCAD** or **CadQuery (Python)** code.

```openscad
// Example: Parametric Sensor Bracket
 = 60;
wall_thickness = 3.0;
inner_width = 45.0;
inner_length = 75.0;
height = 20.0;
screw_hole_r = 2.1; // M4 clearance

difference() {
    cube([inner_width + (wall_thickness * 2), inner_length + (wall_thickness * 2), height], center=true);
    cube([inner_width, inner_length, height + 1], center=true);
    // Mounting lugs
    translate([0, (inner_length/2) + (wall_thickness/2), 0])
        cylinder(r=screw_hole_r, h=height + 2, center=true);
}
```

### Step 2: Headless CLI Slicing
Render and slice deterministically on a local Linux server:
```bash
# 1. Render OpenSCAD to STL
openscad -o bracket.stl bracket.scad

# 2. Slice via OrcaSlicer / PrusaSlicer CLI with calibrated profile
prusa-slicer --load /home/drew/profiles/petg_0.4nozzle.ini --slice --output bracket.gcode bracket.stl
```

### Step 3: Moonraker / Klipper API Job Dispatch
Agents dispatch G-code directly over the local network:
```bash
# Upload and immediately initiate print
curl -X POST "http://printer.local/server/files/upload"   -F "file=@bracket.gcode"   -F "print=true"
```

### Step 4: Vision Monitoring & Closed-Loop Quality Control
- Hook an RTSP or WebRTC camera stream to an inference model (e.g. YOLOv8 or Moonraker Obico plugin).
- If layer shifting or spaghetti is detected with >85% confidence for 3 consecutive frames:
  1. Moonraker API `POST /printer/print/pause`
  2. Agent dispatches alert via local ops webhook or WhatsApp bridge.

---

## 5. Machine Directives for Agents Calling This Skill

When an agent is requested to execute or design a 3D printing workflow:
1. **Specify Filament & Thermal Physics**: Always declare material (PETG, PLA+, TPU, ASA), nozzle diameter, and infill density appropriate for the mechanical load.
2. **Check Dimensional Tolerances**: Account for shrinkage (typically 0.3–0.5% for PETG/ABS) and hole expansion.
3. **Generate Reproducible Artifacts**: Every run must produce:
   - `design.scad` (Source geometry)
   - `build.gcode` (Generated toolpath)
   - `PRINT_RECEIPT.json` (Filament gram weight, estimated time, and cost of goods sold).
