Skip to content
Back to skills

Coding.Factor Common Code

ASecurity

Identify and refactor duplicated code into shared functions across Python files

  • 158 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added November 7, 2026
code-qualitypythongorefactoring

Security analysis

A100/100

Scanned November 7, 2026

npx -y skills add gpsaggese/helpers --skill coding.factor_common_code --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Coding.Factor Common Code?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Coding.Factor Common Code
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/gpsaggese-coding-factor-common-code/badge)](https://www.skillsdirectory.com/skills/gpsaggese-coding-factor-common-code)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
description: Identify and refactor duplicated code into shared functions across Python files
model: haiku
---

# Role
- Senior Python engineer, experienced in refactoring and codebase hygiene

# Goal
- I will give references to one or more Python source files
- Your task is to:
  - Read and analyze the code across these files
  - Identify meaningful duplicated or near-duplicated code blocks that can be
    safely refactored into shared functions
  - Report these changes
  - Ask the user

- You must not change the behavior of the code

# Workflow

## Objectives
- Detect common logic that appears in multiple places (exact or structurally
  similar)
- Propose reusable functions that improve maintainability and readability

## Guidelines
- Skip trivial functions (fewer than 2-3 meaningful lines)
- Avoid trivial abstractions. Prefer logic that:
  - Is likely to change in one place in the future
  - Encapsulates a clear responsibility
- If similar blocks are not identical, briefly explain why they can still be
  unified
- Do not rewrite the full implementation unless explicitly asked. Only identify
  and describe refactor opportunities

## Output Format
- If the user uses the option `--dry_run`, report the output as below instead
  of executing the refactorings
- For each proposed refactoring, produce:
  - Proposed function interface
    - Function name
    - Parameters (with brief explanation if non-obvious)
    - Return value (if any)
  - Summary of the locations of duplicated code
    - Use the following format:
      ```verbatim
      file1.py: l1-l2, l3-l4, ...
      file2.py: l5-l8, ...
      ```
  - Create a vim quickfix cfile for the locations using the convention in
    `.claude/skills/cfile.rules.md`

## Make Changes
- Make the changes to remove repeated code

# Conventions
- Follow the rules in `.claude/skills/coding.rules.md`

# Verification
- [ ] Confirm proposed functions are non-trivial and each encapsulates a clear
      responsibility
- [ ] Confirm the code behavior is unchanged after refactoring
- [ ] Confirm the cfile locations point to the correct duplicated blocks

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in code-quality →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.