ask-matt
MAmattpocock/skills337k4,978 new stars in the last 7 days
Create new FreeCAD AI skills, modify existing skills, and iteratively improve them. Use when users want to create a skill from scratch, update or optimize an existing skill, capture a workflow as a reusable skill, or improve an existing skill's instructions. Also trigger when the user says "turn this into a skill", "make a skill for X", "save this as a command", or similar.
A skill for creating new FreeCAD AI skills and iteratively improving them.
At a high level, the process goes like this:
/command and evaluating the resultYour job is to figure out where the user is in this process and help them move forward. Maybe they say "I want a skill for X" — help them scope it, write the draft, and test it. Or maybe they already have a skill that needs fixing — jump straight to the improvement loop.
Be flexible. If the user says "just write it, I'll test it myself", do that. If they want to iterate 5 times, do that too.
FreeCAD AI users range from experienced CAD engineers to hobbyists who just discovered parametric modeling. Pay attention to context cues — if they use terms like "involute" and "datum plane", match that level. If they say "I want to make a box thing with holes", keep things simple.
Start by understanding what the user wants. The current conversation may already contain a workflow worth capturing (e.g., they say "turn this into a skill"). If so, extract what you can from the conversation — the tools used, the sequence of steps, corrections the user made, dimensions and parameters observed. The user may need to fill gaps, and should confirm before you proceed.
Ask (skip questions they already answered):
Proactively ask about things the user might not think of:
If the current document has relevant objects, inspect them with get_document_state and measure to understand the context.
Pick a short, hyphenated name based on what the skill does. Confirm with the user.
The skill will live at: ~/.config/FreeCAD/FreeCADAI/skills/<name>/
The user invokes it with /<name>.
skill-name/
├── SKILL.md (required — frontmatter `name` + `description`, then instructions)
├── handler.py (optional, FreeCAD AI only — deterministic execute(args) handler)
├── references/ (optional — docs the model reads on demand, subfolders allowed)
│ ├── dimensions.md
│ └── materials.md
├── scripts/ (optional — Python scripts run with run_skill_script)
└── assets/ (optional — templates/data files the scripts open via __file__)
This is the open Agent Skills layout, so the same folder also works in Claude Code,
Codex or Gemini CLI. Start SKILL.md with frontmatter whose name equals the folder name:
---
name: skill-name
description: "What it does and when to use it, in one or two sentences."
---
Quote the description: other harnesses parse it as strict YAML, where an unquoted : breaks it.
Link files with relative Markdown links, e.g. [thread table](references/thread-tables.md);
the model loads them with use_skill(name=..., resource="references/thread-tables.md").
Skills use a layered loading system:
Keep SKILL.md under 200 lines. If you need more detail (dimension tables, material properties, multi-variant instructions), put it in references/ and point to it from SKILL.md:
For standard metric thread dimensions, read `references/thread-tables.md`.
A good SKILL.md includes:
Explain the why behind instructions, not just the what. The LLM is smart — if it understands the reasoning, it can adapt to situations the instructions don't cover explicitly.
Instead of:
ALWAYS use offset=H on the pocket sketch. NEVER pocket from z=0.
Write:
Place the pocket sketch at offset=H (top face of the solid). Pocketing from z=0
creates a hollow that opens upward with no floor — the pocket cuts from the sketch
plane downward into the solid, so starting from the top gives you a proper floor
at the bottom.
More guidance:
create_sketch, pad_sketch, pocket_sketch, etc. The LLM knows all 33 toolsIf the skill benefits from a Python handler, write one with an execute(args) function:
def execute(args):
"""
Args:
args: string with the user's arguments after the /command
Returns:
dict with one of:
{"inject_prompt": "text"} — inject into LLM prompt
{"output": "text"} — display directly to user
{"error": "text"} — show error
"""
Use a handler when the skill needs:
Use the execute_code tool to create the skill directory and write the files:
import os
skill_dir = os.path.expanduser("~/.config/FreeCAD/FreeCADAI/skills/<name>")
os.makedirs(skill_dir, exist_ok=True)
with open(os.path.join(skill_dir, "SKILL.md"), "w") as f:
f.write(skill_md_content)
# Optional:
with open(os.path.join(skill_dir, "handler.py"), "w") as f:
f.write(handler_content)
Tell the user the skill is ready and they can invoke it with /<name>.
After writing the draft, test it. Come up with 2–3 realistic invocations — the kind of thing a real user would type:
/bracket 80x40mm, 4 mounting holes M4, 3mm thick aluminum
/bracket 30x20mm, 2 holes M3
/bracket — just use defaults
Share them with the user: "Here are a few test cases I'd like to try. Do these look right, or would you change any?"
Then run them one at a time. After each run:
get_document_state and measureGeneralize from the feedback. The skill will be used many times with different parameters. Don't overfit to the test cases — if a fix only works for one specific set of dimensions, it's probably too narrow. Think about what principle the fix represents and express that in the instructions.
Keep the prompt lean. Remove instructions that aren't pulling their weight. If the LLM is spending time on unnecessary steps, cut them. Read the actual tool call sequence to see where time is wasted.
Explain the why. If you find yourself writing ALWAYS or NEVER in all caps, that's a sign the instruction needs a reason, not more emphasis. Explain why the thing matters and the LLM will follow through more reliably.
Look for repeated patterns. If every test run independently arrives at the same multi-step workaround, that's a signal the skill should include that approach explicitly — or bundle it in a handler.
If the user already has a skill they want to improve:
For skills that need reference data (dimension tables, material properties, standard specifications), create a references/ directory alongside SKILL.md. Keep each reference file focused on one topic and under 300 lines. Include a brief table of contents at the top of long files.
Example structure for a fastener skill:
fastener/
├── SKILL.md
└── references/
├── metric-bolts.md # M2–M24 dimensions
├── imperial-bolts.md # #2–1" dimensions
└── materials.md # Strength grades, torque specs
Reference files may live in subfolders (references/metric/m3.md). A script in scripts/ runs inside FreeCAD like a command-line program: it sees __name__ == "__main__", sys.argv, and its own __file__, so it can open ../assets/... next to it. Use sys.exit(1) to report failure.
MAmattpocock/skills337k4,978 new stars in the last 7 days
MAmattpocock/skills337k4,978 new stars in the last 7 days
MAmattpocock/skills337k4,978 new stars in the last 7 days
OBobra/superpowers331k4,772 new stars in the last 7 days
AFaffaan-m/ECC315k4,381 new stars in the last 7 days
AFaffaan-m/ECC315k4,381 new stars in the last 7 days