Editing safely
SkillDev toolsUse before writing a new function or helper (it may already exist), and before any rename, signature, or field change — the graph lists every call site.
Available today. Use it from your connected AI after setup.
No other account needed.
Connect ahel once, and every AI you use reads what you have installed.
Then ask your AI: use the Editing safely skill
What this skill tells your AI
The instructions your AI receives, as published by scriptedalchemy/tracedecay in plugin/skills/editing-safely/SKILL.md and read by ahel’s review.
Three phases: probe for existing code before writing, recon every affected site before the first edit, then apply with anchored primitives that re-index the graph in place.
Pre-write duplicate probe (always cheap, run before any new helper)
- By name/keyword →
tracedecay_search; fuzzy twins →tracedecay_similar(parse_cfgvsconfig_parse). - By shape →
tracedecay_signature_search(return type / param substring / async): "any fn taking&Pathand returningResult<Config>?" - By concept →
tracedecay_context(one call,task= what the helper should do) when naming guesses fail. - Deeper audit →
tracedecay_redundancy(min_lines?,similarity_threshold?,path?,max_pairs?): bucketsdefinite/likely/naming_only. Trustdefinite; verifylikely; treatnaming_onlyas a hint. Lazily computed and cached — keeppath/max_pairstight on large repos. - Found one? Inspect with
tracedecay_bodyand reuse or extend it. When consolidating, keep the better-tested copy (checktracedecay_test_mapon both).
Refactor recon (read-only, before the first edit)
- Resolve the target → node ID (
tracedecay:exploring-codeladder). - Recon by refactor type:
- Rename / move →
tracedecay_rename_preview(node_id): every edge where it appears as source or target (preview only — nothing renames). - Signature change →
tracedecay_callers(every call site must adapt) plustracedecay_signature_searchfor shape-twins. - Field rename/remove/new invariant →
tracedecay_field_sites(Struct::field): write sites are the blast radius. - Newly required field →
tracedecay_constructors: every struct-literal site with missing-field lists. - Post-rename name collisions →
tracedecay_similar.
- Rename / move →
- Risk check →
tracedecay_impact(shallowmax_depthfirst) when the target is widely depended on. The recon output is the edit checklist.
Run this read-only recon in one shot for a symbol or Struct::field with
scripts/safe-edit-sequence.sh.
Apply with anchored primitives
- Unique string swap →
tracedecay_str_replace(path,old_str,new_str): fails unlessold_strmatches exactly once — the safest default; use instead of sed/awk. - Several swaps, all-or-nothing →
tracedecay_multi_str_replace(path,replacementsas[[old, new], …]): every pair must match exactly once or the whole edit aborts. - Insert at an anchor →
tracedecay_insert_at(path,anchor= unique string or 1-indexed line,content,before?); around a symbol →tracedecay_insert_at_symbol(symbol,content,position). - Rewrite a whole symbol →
tracedecay_replace_symbol(symbol,new_sourceincluding the declaration line). Refused on unresolved ambiguity — disambiguate rather than forcing. - Structural pattern rewrite →
tracedecay_ast_grep_rewrite(path,pattern,rewrite, ast-grep SGPattern syntax): rewrite every match of a syntactic pattern in one file (e.g.foo($A)→bar(foo($A))); repeat per file for multi-file rewrites. Scope the change first withtracedecay_ast_grep_search(read-only, in-process, whole-tree) to see every match and confirm the pattern before rewriting. - Move a function to another file →
tracedecay_move_symbol(symbol,dest_file,dry_rundefaults true). Relocates the symbol with its docs/attrs and returns an impact report — broken callers, dependencies the body loses at the destination, visibility escalations, collisions, and missingmoddeclarations — as actionable hints. Unambiguous needed imports are auto-inserted at the destination (applied_imports); caller references are reported, never auto-edited. Preview first, then re-run withdry_run: falseto apply.
Porting code
- Baseline →
tracedecay_port_status(source_dir,target_dir,kinds); order →tracedecay_port_order: topological sort — port leaves first, dependents after; never port a symbol before its dependencies. - Per symbol: pull source with
tracedecay_body, map dependencies withtracedecay_callees/tracedecay_callers, confirm the contract withtracedecay_signature, apply with the primitives above. - After each batch: re-run
tracedecay_port_status; typecheck withtracedecay_diagnostics. Cross-branch parity →tracedecay_branch_diff/tracedecay_changelog.
Guardrails
- Probe and recon steps are read-only; the edit primitives mutate files and trigger an in-place re-index — invoke them only when an edit is relevant and respect Cursor approval/run-mode.
- Recon sees only the indexed scope:
pubitems may have external users, and macro-generated or string-keyed references won't appear in the graph — grep once for the bare name before declaring the checklist complete. tracedecay_ast_grep_rewriteshells out to the externalast-grepbinary and is only registered when it is on PATH; if absent, tell the user to install ast-grep rather than approximating the rewrite with regex.- Verify after editing: typecheck via
tracedecay:fixing-build-and-type-errors, then run the affected tests viatracedecay:assessing-impact.
If tools are deferred or MCP fails
- Deferred (names listed without schemas): load once with ToolSearch —
select:tracedecay_search,tracedecay_similar,tracedecay_signature_search,tracedecay_redundancy,tracedecay_rename_preview,tracedecay_str_replace,tracedecay_replace_symbol(one batched call, add others needed) — then call normally. - MCP error/timeout/disconnect: same tool, same args, via shell:
tracedecay tool <name>(seetracedecay:using-the-cli). Never query.tracedecaydatabases directly; never abandon the graph over transport.
Deliverable
Do not end this workflow without: the recon checklist (sites grouped by file),
the files/symbols changed, the helper reused (or its confirmed absence), and
the verification result. Report any tracedecay_metrics: line to the user.
Signals
- GitHub stars
- 73
- Forks
- 5
- Last commit
- Sep 2026
Advanced
- Catalog kind
- skill
- Gateway key
editing-safely- Source
- github.com/scriptedalchemy/tracedecay