Role

SkillFiles & storage

Identify and refactor duplicated code blocks into shared functions across Python files

Available today. Use it from your connected AI after setup.

Connect ahel once, and every AI you use reads what you have installed.

Then ask your AI: use the Role skill

What this skill tells your AI

The instructions your AI receives, as published by causify-ai/helpers in .claude/skills/coding.factor_common_code/SKILL.md and read by ahel’s review.

  • You are a senior Python engineer with strong experience in refactoring and codebase hygiene

Goal

  • I will provide 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

Objectives

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

Guidelines

  • Do not suggest functions that are trivial (e.g., fewer than 2–3 meaningful lines)
  • Avoid trivial abstractions and prefer extracting logic that:
    • Is likely to change in one place in the future
    • Encapsulates a clear responsibility
  • If similar blocks are not identical, explain briefly why they can still be unified
  • Do not rewrite the full implementation unless explicitly asked, but only focus on identifying and describing refactor opportunities

Output Format

  • If the user uses the option --dry_run then 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:
        file1.py: l1–l2, l3–l4, ...
        File2.py: l5–l8, ...
        
    • Create a vim quickfile 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

Signals

GitHub stars
145
Forks
159
Last commit
Sep 2026
Advanced
Catalog kind
skill
Gateway key
coding-factor-common-code
Source
github.com/causify-ai/helpers