home/coding/prompt-analyze-refactor-scope

Prompt Analyze Refactor Scope

GPTClaudeDeepSeek··1,231 copies·updated 2026-07-14
prompt-analyze-refactor-scope.prompt
# Prompt: Analyze Refactor Scope

Use this prompt for one bounded discovery subagent.

## Template

You are analyzing a bounded code area for behavior-preserving structural
refactors only. Do not edit files.

Scope:
- <paths, packages, modules, or symbols>

Task:
1. Check whether the baseline verification path for this scope is currently
   green. If not, say so and keep the output analysis-focused.
2. Record the code state reviewed if it is obvious from local context
   (branch, HEAD, or whether the working tree is dirty).
3. Map the local package or module layout and dependency edges.
4. Build a contract inventory:
   - published API
   - package-private collaboration
   - config or resource names
   - scan roots or reflection targets
   - serialized or wire-format names
5. Identify structural issues only:
   - flat packages
   - cycles, tangles, or hub packages
   - misplaced classes
   - generic utility buckets
   - wrong abstractions
   - duplicated private helpers
   - repeated null-check wrappers
   - feature envy or ownership leakage
   - middle-man wrappers
   - data clumps or selector arguments in local APIs
   - boundary leakage
   - architecture-rule violations or bounded-context leakage
6. Infer which change axis or volatile design decision each active area should
   hide. Use local code and repo evidence first.
7. For each issue, cite the local evidence that shows the preferred pattern.
8. Classify local patterns as `ESTABLISHED`, `LEGACY`, or `ONE-OFF`.
9. Flag framework, module, codegen, or verification hazards that constrain the
   refactor.
10. Recommend the smallest coherent refactor batches.
11. Return enough structured detail to fill
    `docs/refactor-review-report.md` exactly without another discovery pass.

Guardrails:
- Preserve behavior exactly.
- Do not suggest bug fixes or feature changes.
- Do not infer a pattern from a single weak example.
- You are not alone in the codebase; do not revert or overwrite unrelated edits.

Return:
- trigger summary for why this skill applies
- baseline verification status
- code state reviewed, if known
- contract inventory
- local pattern inventory grouped into `ESTABLISHED`, `LEGACY`, and `ONE-OFF`
- issue list ordered by structural impact, and for each issue include:
  - kind
  - priority
  - paths
  - problem
  - local evidence
  - precedent strength
  - recommended pattern
  - behavior-preservation notes
  - boundary or framework notes
  - why now
- framework or boundary checks that must stay true
- recommended batch list, and for each batch include:
  - dependencies
  - goal
  - files in scope
  - allowed edits
  - do-not-change notes
  - boundary checks
  - verification
  - stop conditions
- deferred or rejected changes
- invariants and verification notes per batch
- blockers or uncertainty

when to use it

Community prompt sourced from the open-source GitHub repo tsbhatia/coding-skills-for-agents (no explicit license). A "Prompt Analyze Refactor Scope" style prompt — adapt the placeholders and specifics to your task. Imported as-is and not independently retested here, so check the output before relying on it.

tags

codingcommunitydeveloper

source

tsbhatia/coding-skills-for-agents · no explicit license