refactor-with-validation

refactor-with-validation is a skill for Claude Code, Codex, Cursor from jasperhartong/sketchup-code. It costs 81 tokens per session (1,843 once invoked), scanned A, original, MIT.

A validation workflow for safely refactoring Ruby code used in SketchUp, a 3D modelling program. It compares the model output before and after the code is cleaned up.

In plain words
What is it for?
Use it to remove repetition, reorganise, or clean up SketchUp Ruby code and confirm that it still produces the same model output.
Why use it?
It reduces the risk that shortening or restructuring the code changes the result, while keeping checks limited to the plugin’s own dimensions.

Skill for Claude CodeCodexCursor

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/jasperhartong/sketchup-code/refactor-with-validation
Any agent
npx skills add jasperhartong/sketchup-code --skill refactor-with-validation
Clone the repo
git clone --depth 1 https://github.com/jasperhartong/sketchup-code

Made for: Claude Code, Codex, Cursor.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for refactor-with-validation

README.md
[![agentmods](https://agentmods.dev/badge/skills/jasperhartong/sketchup-code/refactor-with-validation.svg)](https://agentmods.dev/skills/jasperhartong/sketchup-code/refactor-with-validation)
Your own site
<a href="https://agentmods.dev/skills/jasperhartong/sketchup-code/refactor-with-validation"><img src="https://agentmods.dev/badge/skills/jasperhartong/sketchup-code/refactor-with-validation.svg" alt="Measured on agentmods" height="20"></a>
Per session 81 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,843 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00081 $0.01843
Opus 5 $0.00041 $0.00922
Sonnet 5 $0.00016 $0.00369
Haiku 4.5 $0.00008 $0.00184

Measured 5d ago against content hash 7e2fd1309213, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

refactor-with-validation scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 5d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.cursor/skills/refactor-with-validation/SKILL.md · 154 lines

How it starts

The opening of the file, as written. The whole thing — 154 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Refactor with Validation

Safe workflow for refactoring SketchUp Ruby code: capture baseline → refactor → compare → clean up.

Audit helper (reused in Steps 1 & 3)

Important: Audit only the plugin’s dimensions (same selection + sublayer as clear/run). Do not use model.entities.grep(Sketchup::DimensionLinear) — that includes every linear dimension in the model (other plugins, manual dims) and produces wrong counts (e.g. 158 instead of 49).

def fmt_pt(pt)
  "(#{(pt.x*25.4).round(3)}, #{(pt.y*25.4).round(3)}, #{(pt.z*25.4).round(3)})mm"
end
def fmt_vec(v)
  "(#{v.x.round(6)}, #{v.y.round(6)}, #{v.z.round(6)})"
end

# dims_array: only plugin dimensions (from target_entities + sublayer), not model.entities
def audit_dims(dims_array)
  lines = []
  dims_array.each_with_index do |d, i|
    p1 = d.start[1]
    p2 = d.send(:end)[1]
    ov = d.offset_vector
    dir = Geom::Vector3d.new(p2.x - p1.x, p2.y - p1.y, p2.z - p1.z)
    normal = dir.cross(ov)
    normal.normalize! rescue nil
    lines << [
      "dim #{i}: layer='#{d.layer.name}' text='#{d.text}' 3d_dist=#{(p1.distance(p2)*25.4).round(1)}mm",
      "  p1=#{fmt_pt(p1)}  p2=#{fmt_pt(p2)}",
      "  offset=#{fmt_vec(ov)}",
      "  normal=#{fmt_vec(normal)}"
    ].join("\n")
  end
  lines.join("\n")
end

# Returns the array of DimensionLinear that belong to the plugin (current selection, maten sublayer).
def plugin_dims(model)
  inst = Timmerman::SkeletonDimensions.send(:selected_component_instance, model.selection)
  return [] unless inst
  sublayer = Timmerman::SkeletonDimensions.send(:find_or_create_maten_sublayer, model, inst)
  target = Timmerman::SkeletonDimensions.send(:entities_containing_instance, inst)
  target.grep(Sketchup::DimensionLinear).select { |d| d.layer == sublayer }
end

Per dimension this captures:

  • text — displayed measurement (catches wrong values)
  • p1 / p2 — exact 3D world-space anchor coordinates in mm (catches wrong corner/beam edge selection)
  • 3d_dist — scalar distance as a quick sanity check
  • offset — 3D vector positioning the dim line (catches stagger, padding, top-vs-bottom, side-of-beam)
  • normal — computed as normalize((p2−p1) × offset); catches orientation flips that wouldn't show in the other fields. DimensionLinear has no built-in normal method, so we derive it.

Read the full file on GitHub · 154 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 5d ago First seen · 154 lines · 81 tokens per session scan A 7e2fd1309213

Subscribe to this mod's changes

refactor-with-validation is a skill published in the GitHub repository jasperhartong/sketchup-code (5 stars, last pushed 3mo ago), licensed MIT. It adds 81 tokens to every session and 1,843 once invoked, about $0.0004 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.