Loading...
Loading...
Loads OpenSCAD files with full dependency context by parsing use/include statements, resolving library paths, and extracting API surface (modules, functions, parameters). Use when working with OpenSCAD files, debugging rendering issues, understanding module dependencies, or before refactoring. Triggers on "load scad", "scad-load [file]", "load openscad context", "show scad dependencies", or when investigating .scad files. Works with .scad files, BOSL2, woodworkers-lib, NopSCADlib, and project-specific libraries.
npx skill4agent add dawiddutoit/custom-claude scad-load# Load main file with dependency tree
/scad-load workshop/workbenches/mini-workbench.scad
# Output includes:
# - Dependency tree visualization
# - Available modules and functions
# - Customizer parameters
# - Configuration variables
# - File locations (project lib/, system libraries/)# User provides path (absolute or relative to project root)
file_path = "workshop/workbenches/mini-workbench.scad"
# Read file
Read file_path# Find all use/include statements
grep -E '^\s*(use|include)\s*<' file_path
# Example matches:
# use <BOSL2/std.scad>
# include <../../lib/assembly-framework.scad>
# use <woodworkers-lib/std.scad><lib/file.scad>lib/~/Documents/OpenSCAD/libraries/~/.local/share/OpenSCAD/libraries/../../lib/file.scad<BOSL2/std.scad>~/Documents/OpenSCAD/libraries/BOSL2/std.scad~/.local/share/OpenSCAD/libraries/BOSL2/std.scadvisited = set()
stack = []
function load_dependencies(file, depth=0, max_depth=5):
if depth > max_depth:
return "Max depth reached"
if file in stack:
return "CIRCULAR DEPENDENCY: " + " -> ".join(stack + [file])
stack.append(file)
visited.add(file)
# Parse use/include statements
# Recursively load each dependency
stack.pop()# Find module definitions
grep -E '^\s*module\s+\w+\s*\(' file_path
# Example matches:
# module drawer_stack(width, x_start, drawer_start=0) {
# module ww_cabinet_shell() {
# module _helper_function() { # (private, prefixed with _)# Find function definitions
grep -E '^\s*function\s+\w+\s*\(' file_path
# Example matches:
# function asmfw_section_internal_width(section_id) = ...
# function calc_dimensions(w, h) = [w, h, w+h];# Find customizer section comments
grep -E '/\*\s*\[.*\]\s*\*/' file_path
# Example matches:
# /* [Dimensions] */
# /* [Display Options] */
# Parameters follow section comments:
# wall_thickness = 18; // Wall panel thickness
# show_drawers = true; // Show drawer boxes# Find top-level variable assignments
grep -E '^\s*\w+\s*=' file_path | head -20
# Distinguish from parameters by context (before/after customizer sections)_helper()/* [Section] */========================================
OpenSCAD File Context: mini-workbench.scad
========================================
File: /Users/.../workshop/workbenches/mini-workbench.scad
Size: 15.2 KB
Lines: 450
Dependency Tree:
----------------
mini-workbench.scad
├── lib/assembly-framework.scad (project lib)
│ ├── lib/materials.scad (project lib)
│ └── woodworkers-lib/std.scad (system library)
│ ├── woodworkers-lib/planes.scad
│ └── woodworkers-lib/cutlist.scad
├── BOSL2/std.scad (system library)
│ ├── BOSL2/transforms.scad
│ ├── BOSL2/attachments.scad
│ └── BOSL2/shapes3d.scad
└── lib/labels.scad (project lib)
Dependencies Loaded: 11 files
Max Depth Reached: 3 levels
Available Modules (Public):
----------------------------
- mini_workbench() - Main assembly module
- drawer_stack(width, x_start, drawer_start=0) - Creates vertical drawer stack
- dividers() - Renders all vertical dividers
- cabinet_shell() - Outer cabinet box
Available Functions (Public):
------------------------------
- None (uses framework functions)
Customizer Parameters:
----------------------
/* [Display Options] */
show_cabinet = true; // Show cabinet shell
show_drawers = true; // Show drawer boxes
show_faceplates = true; // Show drawer faces
show_runners = true; // Show drawer runners
show_dividers = true; // Show vertical dividers
/* [Dimensions] */
total_width = 1650; // Assembly total width
assembly_height = 500; // Internal height
assembly_depth = 580; // Front-to-back depth
Configuration Variables:
------------------------
ASMFW_SECTION_IDS = ["A", "B", "C", "D", "E"]
ASMFW_SECTION_WIDTHS = [253, 562, 562, 153, 120]
ASMFW_TOTAL_WIDTH = 1650
ASMFW_ASSEMBLY_HEIGHT = 500
ASMFW_ASSEMBLY_DEPTH = 580
Framework Functions Available:
-------------------------------
(from lib/assembly-framework.scad)
- asmfw_section_internal_width(section_id)
- asmfw_section_x_start(section_id)
- asmfw_section_x_end(section_id)
- asmfw_drawer_box_width(section_id)
- asmfw_faceplate_width(section_id)
- asmfw_runner_x_positions(section_id)
Key Insights:
-------------
✓ Uses assembly framework for automatic positioning
✓ 5-section cabinet (A, B, C, D, E)
✓ Drawer stacks in sections B and C
✓ Side-access tray in section D
✓ Tall drawer in section A
✓ All dimensions driven by framework configuration
Next Steps:
-----------
- Modify customizer parameters to change display
- Adjust ASMFW_SECTION_WIDTHS to resize sections
- Add new modules using framework functions
- Update drawer stack configurations in sections
========================================parse_scad.pyresolve_paths.pydependency_graph.pyopenscad-path-resolution.mdapi-extraction-patterns.mdlibrary-locations.mdexample-output-simple.mdexample-output-complex.mdexample-circular-dependency.md✅ Loaded: workshop/workbenches/mini-workbench.scad
✅ Dependencies: 11 files resolved
✅ Modules: 4 public, 2 private
✅ Functions: 0 public (uses framework)
✅ Customizer params: 9 parameters in 2 sections
✅ No circular dependencies detected
✅ All library paths resolved
Ready to work with this file.❌ Failed to load: workshop/cabinets/broken.scad
Issues Found:
1. Missing dependency: lib/missing-framework.scad
- Referenced at line 5: include <lib/missing-framework.scad>
- File not found in project lib/ or system libraries/
2. Circular dependency detected:
- a.scad -> b.scad -> c.scad -> a.scad
3. Unresolved library: CustomLib/helper.scad
- Not found in ~/Documents/OpenSCAD/libraries/
- Not found in ~/.local/share/OpenSCAD/libraries/
Recommendations:
- Install missing library: CustomLib
- Fix circular dependency in a.scad/b.scad/c.scad
- Create missing file: lib/missing-framework.scad/* [Section] */_private()<file.scad>lib/~/Documents/OpenSCAD/libraries/~/.local/share/OpenSCAD/libraries/../lib/file.scaduse <file.scad>include <file.scad>