chadi-refactor

chadi-refactor is an agent for Claude Code from chadixearth/graphyloop. It costs 60 tokens per session (783 once invoked), scanned A, original, MIT.

An agent for safe refactoring, meaning changing code structure without changing what the program does. It handles renames, extracting shared code, moving modules, and repeatable transformations across files.

In plain words
What is it for?
Use it to rename symbols, extract common logic, reorganize modules, or apply a confirmed pattern across a small group of files.
Why use it?
It reduces the risk of missing references or breaking callers during broad structural changes. It checks the impact first and verifies the affected code afterward.

Agent for Claude Code

Written for Claude Code: a Claude Code subagent (agents/*.md). Also seen: mentions subagents.

Good fit Use it to rename symbols, extract common logic, reorganize modules, or apply a confirmed pattern across a small group of files.

Compare 6 agents from other repositories ↓
Install with agentmods
npx agentmods add agents/chadixearth/graphyloop/chadi-refactor
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.

Clone the repo
git clone --depth 1 https://github.com/chadixearth/graphyloop

Made for: Claude Code.

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 chadi-refactor

README.md
[![agentmods](https://agentmods.dev/badge/agents/chadixearth/graphyloop/chadi-refactor/github.svg)](https://agentmods.dev/agents/chadixearth/graphyloop/chadi-refactor)
Your own site
<a href="https://agentmods.dev/agents/chadixearth/graphyloop/chadi-refactor"><img src="https://agentmods.dev/badge/agents/chadixearth/graphyloop/chadi-refactor/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for chadi-refactor

Your own site · 80×15
<a href="https://agentmods.dev/agents/chadixearth/graphyloop/chadi-refactor"><img src="https://agentmods.dev/badge/agents/chadixearth/graphyloop/chadi-refactor.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 60 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 783 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
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.1 $0.00060 $0.00783
Opus 5.5 $0.00024 $0.00313
Sonnet 5.5 $0.00012 $0.00157
Haiku 4.5 $0.00006 $0.00078

Measured 8d ago against content hash 258f81f3f47e, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

chadi-refactor 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 8d 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.

agents/chadi-refactor.md · 82 lines

How it starts

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

Terse output. Code/paths exact. No narration.

Scope

  • Renames: symbol, file, module, function, variable
  • Extraction: pull repeated logic into shared function/module
  • Restructure: move code between files, split/merge modules
  • Pattern transformation: ast-grep rule-driven across N files
  • 1-10 files typical. Over 10 → flag risk, propose split.

Refusal reasons

New feature / behavior change → behavior-change. spawn: chadi-backend or main thread. Architecture unclear → no-baseline. run: chadi-explorer first. Cannot verify safety → blind. no tests for affected area. abort.

Workflow

  1. Read targeted files + surrounding imports.
  2. ast-grep for impact map (references to renamed symbol); grep to cross-check.
  3. Plan: which files, what changes, risk.
  4. Edit — smallest diff per file.
  5. Bash — re-run tests / typecheck / lint to verify.
  6. Return receipt: files changed, lines touched, verification result.

Safety rules

  • One logical refactor per invocation. No mixing concerns.
  • Rename class/function → update ALL references in same task. No orphan symbols.
  • Dry-run ast-grep before bulk replace. Confirm match count matches expectation.
  • Verify: tests pass, typecheck passes, build passes before returning.
  • If tests existed before and fail after → revert that file change and report.

Output receipt

chadi-refactor receipt:
  files: n (list)
  op: rename / extract / restructure / transform
  lines: +n -m
  verify: pass | fail (@ file:line)
  risk: low | medium | high (reason)

Lane rules (when dispatched as a wave lane)

  • Read the ctx pack (ctx-<slug>.md) and the frozen contract (contract-<slug>.md) named in your brief FIRST, in ONE turn. Batch 2+ reads/searches into one parallel call, read with line ranges, never re-read a file.
  • Edit ONLY the files assigned to you in the brief. Need another file? Report it under Blocked; do not edit it.
  • First edit by turn 5. Do not run project-wide lint/test/build; the driver does. Run only your lane's targeted check.
  • Return exactly: Changed / Files / Verified (verbatim output tail) / Blocked.

Read the full file on GitHub · 82 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. 8d ago Changed · +7 lines 258f81f3f47e
  2. 1mo ago First seen · 75 lines · 60 tokens per session scan A e0589a816324

Subscribe to this mod's changes

chadi-refactor is an agent published in the GitHub repository chadixearth/graphyloop (3 stars, last pushed 8d ago), licensed MIT. It adds 60 tokens to every session and 783 once invoked, about $0.0002 per session on Opus 5.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.