ECC: Command for GitHub Copilot

.github/prompts/refactor.prompt.md

refactor is a command for GitHub Copilot from affaan-m/ECC. It costs 14 tokens per session (413 once invoked), scanned A, original, MIT.

A command for restructuring code by removing dead code, reducing duplication, and simplifying organization without changing its observable behavior. It requires tests to pass before and after the changes.

In plain words
What is it for?
Removing unused code, extracting repeated logic, splitting oversized functions or files, and improving names and structure.
Why use it?
It makes maintenance changes safer by defining the intended behavior and checking that the cleanup preserves it.

Command for GitHub Copilot

Written for GitHub Copilot: a Copilot chat mode or prompt. Also seen: agent in frontmatter.

This is affaan-m/ECC's own configuration. It tells GitHub Copilot how to work on ECC itself, so it is not a mod to install elsewhere. Copy it as a starting point and replace the rules that are about this project. Everything ECC configures →

Part of the ecc plugin — 70 skills, 58 commands, 68 agents, 1 MCP server shipped together

About the project

ECC is a toolkit that organizes and improves how coding agents work through skills, memory, security checks, research practices, and related extensions. It is for developers using agents such as Claude Code, Codex, OpenCode, and Cursor.

affaan-m/ECC · 253,158 stars · on GitHub · ecc.tools

Reuse

Borrowing it

Nothing to install: this file belongs to affaan-m/ECC. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.

Copy the file
curl -O https://raw.githubusercontent.com/affaan-m/ECC/main/.github/prompts/refactor.prompt.md
Clone the repo
git clone --depth 1 https://github.com/affaan-m/ECC

Made for: GitHub Copilot.

Or install ecc, the plugin that ships this one along with the rest of its 70 skills, 58 commands, 68 agents, 1 MCP server.

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

README.md
[![agentmods](https://agentmods.dev/badge/commands/affaan-m/ecc/refactor/github.svg)](https://agentmods.dev/commands/affaan-m/ecc/refactor)
Your own site
<a href="https://agentmods.dev/commands/affaan-m/ecc/refactor"><img src="https://agentmods.dev/badge/commands/affaan-m/ecc/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 refactor

Your own site · 80×15
<a href="https://agentmods.dev/commands/affaan-m/ecc/refactor"><img src="https://agentmods.dev/badge/commands/affaan-m/ecc/refactor.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 14 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 413 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.00014 $0.00413
Opus 5 $0.00007 $0.00206
Sonnet 5 $0.00003 $0.00083
Haiku 4.5 $0.00001 $0.00041

Measured yesterday against content hash 1fe05960dc20, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-08, from the pricing page.

Security

Grade A, and why

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 yesterday.

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.

.github/prompts/refactor.prompt.md · 51 lines

What it actually says

Refactor & Cleanup

Improve the internal structure of the selected code without changing its observable behavior. All tests must pass before and after.

Before Starting

  • Confirm the test suite is passing.
  • Note the current coverage baseline.
  • Identify the scope: single function, file, or module?

Refactoring Targets

Dead Code Removal

  • Unused variables, imports, functions, and exports
  • Commented-out code blocks (delete, don't leave as comments)
  • Feature flags that are permanently enabled/disabled
  • Unreachable branches

Duplication Reduction

  • Repeated logic that can be extracted into a shared utility
  • Copy-pasted blocks differing only in a parameter (extract with that parameter)
  • Inline constants that appear in multiple places (extract to named constants)

Structure Improvements

  • Functions over 50 lines → break into smaller, named steps
  • Files over 800 lines → extract cohesive sub-modules
  • Nesting deeper than 4 levels → extract early-return guards or helper functions
  • Mixed concerns in one function → split into focused single-responsibility functions

Naming

  • Rename variables/functions whose names don't match their behavior
  • Replace magic numbers and strings with named constants
  • Align naming with the domain language used elsewhere in the codebase

Constraints

  • No behavior changes — refactoring is purely structural.
  • One concern at a time — do not mix refactoring with feature work or bug fixes.
  • Keep tests green — run the suite after each meaningful change.
  • Don't add abstractions preemptively — extract only what has already proven to be duplicated (rule of three).

Output

After refactoring, summarize:

  • What was removed (dead code, duplication)
  • What was extracted (new utilities, constants)
  • What was renamed and why
  • Coverage before / after (should not decrease)
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. yesterday First seen · 51 lines · 14 tokens per session scan A 1fe05960dc20

Subscribe to this mod's changes

refactor is a command published in the GitHub repository affaan-m/ECC (253,158 stars, last pushed today), licensed MIT. It adds 14 tokens to every session and 413 once invoked, about $0.0001 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-09-07.