Agent skill

Refactor

by termide in termide/termide

Full-workspace code quality analysis and refactoring with validation

MITAuto-check passedDevelopment

Install Refactor

skills CLI
$ npx skills add termide/termide --skill refactor -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install termide/termide refactor --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/termide/termide.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.agents/skills/refactor .claude/skills/refactor && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
refactor
GitHub stars
171
Token cost
~2.8k tokens
SKILL.md length
1,169 words
Files
1
Skills in repo
3
Repo updated
First seen
Licence
MIT

At a glance

Full-workspace code quality analysis and refactoring with validation

  • Works in 5 steps: Exploration → Diagnosis → Report and prioritisation → …
  • Tasks that involve Refactoring
  • SKILL.md covers Process and Rules
  • Calls cargo and git

What it does

Refactor is an agent skill from termide/termide. Full-workspace code quality analysis and refactoring with validation

Its SKILL.md is about 2.8k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in Development, covering Refactoring and Code quality. It works with Git, Model Context Protocol, Rust and SQL. The repository describes itself as: All-in-one terminal workspace for desktops and servers: editor with LSP, file manager with SFTP/FTP, terminal, git, database viewer and a coding agent in one zero-config static… The licence is MIT.

When your agent uses it

  • Tasks that involve Refactoring
  • Tasks that involve Code quality

Example prompts

  • “/refactor”

Requirements

  • Pre-approved tools (allowed-tools): Read, Grep, Glob, Bash(cargo check*), Bash(cargo clippy*), Bash(cargo test*), Bash(cargo fmt*), Bash(cargo tree*), Bash(cargo audit*), Bash(cargo outdated*), Bash(cargo machete*), Bash(cargo deny*), Bash(cargo mutants*), Bash(cargo tarpaulin*), Bash(cargo udeps*), Bash(git status*), Bash(git diff*), Bash(git stash*), Bash(git log*), Bash(wc *), Bash(grep*), Edit, Write, Task

Workflow steps

5 steps, taken from the step headings in SKILL.md.

  1. Exploration
  2. Diagnosis
  3. Report and prioritisation
  4. Execution
  5. Validation

What it can do on your machine

Read from SKILL.md and the folder at commit 5c550fc. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves these tools, so the agent can use them without asking each time:

    • Read
    • Grep
    • Glob
    • Bash(cargo check*)
    • Bash(cargo clippy*)
    • Bash(cargo test*)
    • Bash(cargo fmt*)
    • Bash(cargo tree*)
    • Bash(cargo audit*)
    • Bash(cargo outdated*)

    …and 14 more on the same allowed-tools line.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • cargo
    • git

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md. Its commands use git, which can reach the network depending on how they are called.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Refactor loads about 2.8k tokens when it runs. Until then it costs about 19 tokens; SKILL.md has 1,169 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~19
When it runs · the whole SKILL.md, loaded when a task matches
~2.8k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from termide/termide at commit 5c550fc, republished under its MIT licence (© termide). 1,169 words, ~2,819 tokens.

Download SKILL.mdSave it as .claude/skills/refactor/SKILL.md (or your agent's skills folder).
name
refactor
description
Full-workspace code quality analysis and refactoring with validation
allowed-tools
Read, Grep, Glob, Bash(cargo check*), Bash(cargo clippy*), Bash(cargo test*), Bash(cargo fmt*), Bash(cargo tree*), Bash(cargo audit*), Bash(cargo outdated*), Bash(cargo machete*), Bash(cargo deny*), Bash(cargo mutants*), Bash(cargo tarpaulin*), Bash(cargo udeps*), Bash(git status*), Bash(git diff*), Bash(git stash*), Bash(git log*), Bash(wc *), Bash(grep*), Edit, Write, Task
user-invocable
true

Refactor

Full-workspace code quality analysis and incremental refactoring with continuous validation.

This skill is intended for periodic whole-codebase refactoring passes, not per-branch or per-diff cleanup. It does not accept --diff / --staged / --since arguments.

Platform note: agents that support frontmatter permissions may use allowed-tools and user-invocable. Other agents should ignore unsupported fields and follow the workflow below. When platform-specific orchestration or memory features are unavailable, degrade gracefully and continue with the equivalent local workflow.

Arguments (optional):

  • Path or crate: /refactor crates/app — limit scope to one directory
  • No arguments — analyze the entire workspace

Process

Phase 1: Exploration
  1. Read project instruction and planning files if present, for example AGENTS.md, CLAUDE.md, and PRD.md. Also read any project or agent memory/notes files if present for intentional_placeholder_*, feedback_*, or similar notes that inform what to skip.
  2. Collect baseline metrics — run in parallel, each one optional (if a tool is absent, emit an info line in the report, do not fail):
    • cargo clippy --workspace --all-targets 2>&1 — warning count.
    • cargo test --workspace 2>&1 — green baseline? If tests fail or code doesn't compile, report and stop.
    • Glob + wc -l — LOC per crate, files > 400 LOC.
    • cargo tree -d — duplicated dependencies.
    • cargo audit — CVE list. If severity ≥ Medium, flag but continue.
    • cargo outdated --root-deps-only — major-behind deps.
    • cargo machete — unused [dependencies] entries.
    • cargo udeps — unused deps (secondary, if machete absent).
    • git log --numstat --since="6 months ago" → top-10 files by churn (hotspot candidates for splitting).
    • grep -rn "TODO\|FIXME\|HACK\|XXX" --include="*.rs" — from repo root, not from crates/ (see Rules below).
    • Cyclomatic-complexity proxy: grep -c "match\|if\|for\|while" on the ten largest .rs files.
Phase 2: Diagnosis

Analyze code across the categories below. For large scope, use parallel subagents or parallel analysis passes if the platform supports them, ideally one per category or related group of categories.

Analysis checklist

Architecture (SOLID)

  • Files > 400 LOC with multiple public types — splitting candidates.
  • Modules with > 1 responsibility.
  • Hard dependencies between modules (concrete types where a trait would decouple).
  • Open/Closed violations: match on types that are expected to grow.

Legitimate exceptions to "1 file = 1 type": Error+ErrorKind pairs, Builder+Target, small private helpers (< 30 LOC), related DTO families (Request/Response), typestate marker types, newtype wrapper collections.

Module coupling / cohesion

  • Crate dependency graph is unidirectional (core ← mid ← app).
  • No circular deps between modules within a crate.
  • No excessive pub — types/functions public without need (downgrade to pub(crate) / pub(super)).
  • Crate does not know implementation details of another crate (leaky abstraction).
  • Changing one module does not cascade into unrelated modules.

Duplication (DRY)

  • Repeated code blocks (> 5 lines, > 2 occurrences).
  • Similar match patterns across different files.
  • Copy-pasted error handling.

Dead code

  • Grep usages from repo root, not from crates/. Binary crate in src/ is a legitimate caller (previous incident with check_git_available / ram_usage_percent was caused by grepping only crates/).
  • Unused use, functions, types, constants.
  • Commented-out code.
  • Unreachable branches.
  • Confidence tagging:
    • HIGH — unused private / pub(crate) in leaf module, no callers.
    • MEDIUM — pub in inner crate, no callers found via grep.
    • LOW — enum variant, trait impl, or item with #[allow(dead_code)] nearby — likely intentional placeholder.
  • Skip items already noted as intentional in project or agent memory/notes files (e.g. ForceSave, dead enum variants in vfs_state.rs/keyboard.rs, format_bytes x3, ConflictResolution x3 across layers).

Performance

  • Unnecessary .clone() / .to_string() / .to_owned() where a reference suffices.
  • O(n²) loops (nested iterations over collections).
  • Repeated HashMap/Vec lookups inside a loop.
  • Allocations in hot paths (see also Allocations category below).

Error boundaries

  • Consistent error types at crate boundaries (From / thiserror).
  • unwrap() / expect() in production code — replace with ? or explicit handling.
  • Lost error context (.map_err(|_| ...) without information).
  • Panic instead of Result at input boundaries (user, DB, network).

Security

  • Integrate cargo audit / cargo deny check licenses output here (do not split into a separate step).
  • SQL queries via string concatenation instead of parameterized.
  • Secrets / tokens hardcoded or logged.
  • Unvalidated user input (path traversal, XSS).
  • fs::*(user_input_path) without canonicalize() + starts_with() check — path traversal risk.
  • Command::new(user_input) or shell-expansion of user input — command injection.
  • Magic numbers and hardcoded config that should be parameters.

Style and idioms

  • Inconsistent naming.
  • Missing #[must_use] on pure / builder methods.
  • Over-abstractions with no usage.
  • Uncovered edge cases in tests (empty input, errors, overflow).

Concurrency (Rust-specific)

  • Arc<Mutex<T>> where locked guard is used mostly for reads (grep the ratio of .lock() read accesses vs mutations) — Arc<RwLock<T>> candidate.
  • .await inside a .lock() guard — deadlock risk.
  • tokio::spawn without an abort handle for long-running tasks (leaks on shutdown).
  • Shared mutable state without Send / Sync markers where the compiler would accept them.

API stability

  • pub enum without #[non_exhaustive] on a cross-crate boundary.
  • pub in a child module re-exported via pub use only for one caller — downgrade candidate to pub(crate).
  • Breaking changes to pub API without a version bump.

Allocations / hot path (TUI-specific)

  • .to_string() / format! / Vec::new() / vec![] inside render_*, tick_*, draw_*, update_* functions.
  • Config cloned per frame — verify Arc<Config> pattern is used.
  • Cow<str> candidates: functions taking &str that sometimes need an owned String.

Testing quality

  • Non-hermetic tests: std::env::set_var, global state mutation inside #[test].
  • #[ignore] without a comment explaining why.
  • Assertions without a message on complex equality (assert_eq! on a large struct).
  • Coverage gap in critical paths (if cargo-tarpaulin is available, highlight files with < 50%).

Observability

  • println! / eprintln! in production code (not #[test] / examples) — should be log::*.
  • let _ = <Result> — errors swallowed without log::warn!.
  • Long-running operations without tracing span or progress.
Show full SKILL.md (309 more words)Show less
Phase 3: Report and prioritisation

Each finding gets two tags:

Impact:  HIGH / MED / LOW
  HIGH  — > 100 LOC reduction OR removes a bug class OR unblocks a perf fix
  MED   — 20–100 LOC reduction OR consolidates a recurring pattern
  LOW   — < 20 LOC OR stylistic

Risk:    SAFE / CAREFUL / BREAKING
  SAFE      — private internals, no API surface change, covered by tests
  CAREFUL   — pub(crate) API, hot path, thread boundary
  BREAKING  — pub API, schema/config format, semantic change

Default execution order: HIGH-SAFE → MED-SAFE → HIGH-CAREFUL → LOW-SAFE → MED-CAREFUL. BREAKING findings are shown but never executed without explicit user approval.

Output format (terminal, do not create report files):

## Findings (ROI-sorted)

### 🟢 HIGH-SAFE (execute automatically)
1. **<short title>** — path/to/file.rs, path/to/other.rs
   Why: <one-sentence justification + evidence>.
   Effort: ~N min · Risk: SAFE (<reason>).

### 🟡 MED-CAREFUL (propose, require approval)
2. **<short title>** — path/to/file.rs
   Why: …
   Effort: ~N min · Risk: CAREFUL (<reason>).

### 🔴 BREAKING (report only, do not execute)
3. …

### 📦 Ecosystem
- cargo-audit: N advisories.
- cargo-outdated: N major-behind deps.
- cargo-machete: N unused crates.
- cargo-tarpaulin: workspace coverage X% (only if available).

## Category counts

| Category     | Found | HIGH | MED | LOW |
|--------------|------:|-----:|----:|----:|
| Architecture |   …   |  …   |  …  |  …  |
| …            |   …   |  …   |  …  |  …  |

Baseline: X clippy warnings, Y workspace LOC, Z tests passing.

Auto-mode:

  • If auto-mode is detected by surrounding context, do not pause for interactive questions.
  • Auto-execute all HIGH-SAFE and MED-SAFE findings.
  • Leave CAREFUL and BREAKING in the report for the user to review.

Non-auto:

  • Ask the user which categories to fix using the platform's interactive prompt mechanism, with SAFE findings preselected when supported.
  • Ask for budget: quick cleanup / full refactoring.
Phase 4: Execution

For each fix:

  1. Read the file, understand context.
  2. Make the change via Edit.
  3. cargo check — still compiles?
  4. If behaviour is affected — cargo test --workspace.
  5. Move to the next fix.

On compilation or test failure — revert the change and move on.

Commit boundaries: do not auto-commit. Let the user review the final diff and commit.

Phase 5: Validation
bash
cargo fmt --check
cargo clippy --workspace --all-targets -- -D warnings
cargo test --workspace

Compare with baseline: warnings removed, LOC deleted/changed, tests still green.

Rules

  • Grep for dead code from the repository root, not from crates/. Binary crate in src/ is a legitimate caller.
  • Before proposing a dead-code or refactor finding, cross-check project or agent memory/notes files for intentional_placeholder_* entries and skip those silently.
  • If an ecosystem tool (cargo-machete, cargo-mutants, cargo-audit, etc.) is not in PATH, emit an info line and continue — do not fail.
  • BREAKING findings are reported but never executed without explicit user consent.
  • In auto-mode, do not interrupt execution for SAFE actions.
  • Do not create abstractions "for the future" — only when duplication already exists.
  • Do not change public API without explicit consent.
  • Do not touch files you haven't read.
  • Do not expand refactoring beyond the agreed scope.
  • Atomic changes: one fix at a time, verify after each.
  • Output to terminal, not to report files.
  • Communicate in the user's language.

© termide, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in .agents/skills/refactor of termide/termide.

Open the folder on GitHubat commit 5c550fc

Compare with similar skills

Refactor next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Refactor compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Refactor this skilltermide/termide171—~2.8kAutomated safety check: PassMIT
Graph-Guided Safe Refactoringtirth8205/code-review-graph32k1 repos~332Automated safety check: PassMIT
Worktrunk CLI Output Rulesmax-sixty/worktrunk8.9k—~12kAutomated safety check: PassCustom licence
Coding Agentmastra-ai/mastra29k—~2.3kAutomated safety check: PassCustom licence
Release Datafusion Ducklakedatafusion-contrib/datafusion-ducklake182—~903Automated safety check: PassApache-2.0
Review Changesgemwalletcom/core149—~2.4kAutomated safety check: NotesMIT

Similar skills

  • Graph-Guided Safe Refactoring

    tirth8205/code-review-graph

    Plans a refactor from a code dependency graph, previews renames before applying them and checks that the final impact matches the plan.

    32k GitHub starsUsed in 1 repo~332 tokens
    DevelopmentAuto-check passed
  • Worktrunk CLI Output Rules

    max-sixty/worktrunk

    CLI output standards for worktrunk: message functions, ANSI color nesting and the shell integration that changes directory after the wt command exits.

    8.9k GitHub stars~12k tokensUpdated today
    DevelopmentAuto-check passed
  • Coding Agent

    mastra-ai/mastra

    Authoring playbook for building agents that write, edit, review, or refactor code.

    29k GitHub stars~2.3k tokensUpdated today
    DevelopmentAuto-check passed
  • Release Datafusion Ducklake

    datafusion-contrib/datafusion-ducklake

    Prepare and publish a new release of datafusion-ducklake to crates.io

    182 GitHub stars~903 tokensUpdated today
    DevelopmentAuto-check passed
  • Review Changes

    gemwalletcom/core

    Review and fix local git changes against Gem Wallet Core coding standards and patterns

    149 GitHub stars~2.4k tokensUpdated 4 mo ago
    DevelopmentAuto-check: notes
  • Release Crate

    r3bl-org/r3bl-open-core

    Publish a crate release to crates.io with changelog, standalone release notes, git tag, and GitHub release.

    485 GitHub stars~2.4k tokensUpdated today
    DevelopmentAuto-check passed

More from termide/termide

  • Release Management

    termide/termide

    Prepare and publish a project release with version updates, changelog generation, tagging, and validation

    171 GitHub stars~6.8k tokensUpdated today
    Auto-check passed
  • Commit

    termide/termide

    Collect uncommitted changes and create a semantic commit with a descriptive message

    171 GitHub stars~499 tokensUpdated today
    Auto-check: notes

Categories

Questions about Refactor

What does Refactor do?

Full-workspace code quality analysis and refactoring with validation. Refactor is an agent skill from termide/termide.

When should I use Refactor?

Refactor fits situations like: tasks that involve Refactoring; tasks that involve Code quality.

How do I install Refactor in Claude Code?

Run `npx skills add termide/termide --skill refactor -a claude-code`. Or copy the skill folder (.agents/skills/refactor in termide/termide) into .claude/skills/refactor in your project. Claude Code loads it when a task matches its description.

How do I install Refactor in Codex?

Run `npx skills add termide/termide --skill refactor -a codex`. Or copy the skill folder (.agents/skills/refactor in termide/termide) into .agents/skills/refactor in your project. Codex loads it when a task matches its description.

Can I use Refactor in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add termide/termide --skill refactor -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/refactor, .gemini/skills/refactor, .github/skills/refactor and .opencode/skills/refactor in your project.

What does Refactor need to run?

Going by SKILL.md and its folder, Refactor needs the command-line tools its instructions call (cargo and git). Its frontmatter pre-approves these tools: Read, Grep, Glob, Bash(cargo check*), Bash(cargo clippy*), Bash(cargo test*), Bash(cargo fmt*), Bash(cargo tree*), Bash(cargo audit*), Bash(cargo outdated*), Bash(cargo machete*), Bash(cargo deny*), Bash(cargo mutants*), Bash(cargo tarpaulin*), Bash(cargo udeps*), Bash(git status*), Bash(git diff*), Bash(git stash*), Bash(git log*), Bash(wc *), Bash(grep*), Edit, Write, Task.

Does Refactor access the network?

SKILL.md contains no URLs. Its commands use git, which can reach the network depending on how they are called. This is read from the text; nothing was executed.

Is Refactor safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Refactor use?

Refactor is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Refactor use?

About 2.8k tokens (SKILL.md is roughly 11k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Refactor?

Skills that share tags, products or a category with Refactor: Graph-Guided Safe Refactoring (tirth8205/code-review-graph, 32k stars), Worktrunk CLI Output Rules (max-sixty/worktrunk, 8.9k stars), Coding Agent (mastra-ai/mastra, 29k stars) and Release Datafusion Ducklake (datafusion-contrib/datafusion-ducklake, 182 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Refactor?

termide (a GitHub organization) maintains it in termide/termide, which has 171 GitHub stars. The repository holds 3 skills in this directory. The repository was last updated on October 6, 2026.

Source: termide/termide on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.