# Refactor

> Clean up dead code, reduce duplication, and simplify structure without changing behavior. Use when refactoring, removing dead code, reducing duplication, or simplifying structure without changing behavior.

- **Type:** Skill
- **Install:** `agentstack add skill-ksed8-cc-loopkit-refactor`
- **Verified:** Yes — security-reviewed for prompt injection and unsafe behavior
- **Seller:** [ksed8](https://agentstack.voostack.com/s/ksed8)
- **Installs:** 0
- **Category:** [Agent Skills](https://agentstack.voostack.com/c/agent-skills)
- **Latest version:** 0.1.0
- **License:** MIT
- **Upstream author:** [ksed8](https://github.com/ksed8)
- **Source:** https://github.com/ksed8/cc-loopkit/tree/main/.claude/skills/refactor

## Install

```sh
agentstack add skill-ksed8-cc-loopkit-refactor
```

Requires the [AgentStack CLI](https://agentstack.voostack.com/docs/cli). Works with Claude Code, Cursor, and any MCP-compatible agent.

## About

# 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)

## Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

- **Author:** [ksed8](https://github.com/ksed8)
- **Source:** [ksed8/cc-loopkit](https://github.com/ksed8/cc-loopkit)
- **License:** MIT

Install and usage instructions live in the source repository linked above.

## Pricing

- **Free** — Free

## Security capabilities

Automated source analysis of v0.1.0 — what this tool can access:

- **Network access:** no
- **Filesystem access:** no
- **Shell / process execution:** no
- **Environment & secrets:** no
- **Dynamic code execution:** no

*"Yes" means the capability is present in the source — more access means more to trust, not that it is unsafe.*


## Versions

- **0.1.0** — security scan: passed — Imported from the upstream source.

## Links

- Listing page: https://agentstack.voostack.com/l/skill-ksed8-cc-loopkit-refactor
- Seller: https://agentstack.voostack.com/s/ksed8
- Browse the marketplace: https://agentstack.voostack.com/browse

---
Listed on AgentStack — the marketplace for AI agent skills and MCP servers. Every listing is security-reviewed. Creators keep 70%.
