Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
majiayu000 avatar

Code Reuse Enforcement

  • 1 installs
  • 534 repo stars
  • Updated August 4, 2026
  • majiayu000/claude-skill-registry

Enforces discovering existing constants, enums, and utilities before writing new code to prevent duplication and magic strings.

About

A guardrail that requires discovering existing constants, enums, and utilities before writing new code to prevent magic strings and duplicate utilities in the AIDB codebase. A developer uses it before adding literals or utility functions to keep code DRY.

  • Discovery-first workflow: check constants, enums, then utilities before coding
  • Includes a pre-commit enforcement checklist against hardcoded URLs, paths, and states

Code Reuse Enforcement by the numbers

  • 1 all-time installs (skills.sh)
  • Ranked #982 of 1,352 Code Review & Quality skills by installs in the Skillselion catalog
  • Data as of Aug 5, 2026 (Skillselion catalog sync)
npx skills add https://github.com/majiayu000/claude-skill-registry --skill code-reuse-enforcement

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs1
repo stars534
Last updatedAugust 4, 2026
Repositorymajiayu000/claude-skill-registry

What it does

Enforces discovering existing constants, enums, and utilities before writing new code to prevent duplication and magic strings.

Files

SKILL.mdMarkdownGitHub ↗

Code Reuse Enforcement

CRITICAL GUARDRAIL: Discover existing code BEFORE writing new code.

Why This Matters

  • Magic strings scatter across 50 files instead of 1 constant
  • Duplicate utilities create maintenance nightmares
  • Inconsistent values break features silently

______________________________________________________________________

The Discovery-First Workflow

BEFORE writing ANY code with literals or utilities:

1. Check Constants - URLs, paths, timeouts, limits, env var names 1. Check Enums - States, statuses, types, actions 1. Check Utilities - Path ops, env reading, file ops, validation

Quick Reference: discovery-catalog.md

______________________________________________________________________

Common Violations

Magic Strings

# ❌ BAD
url = "https://ai-debugger.com/support"
log_dir = ".aidb/log"
debug = os.getenv("AIDB_LOG_LEVEL", "INFO")

# ✅ GOOD
from aidb_common.constants import AIDB_BASE_URL
from aidb_common.path import get_aidb_log_dir
from aidb_logging.utils import get_log_level

url = f"{AIDB_BASE_URL}/support"
log_dir = get_aidb_log_dir()
log_level = get_log_level(default="INFO")

Magic Numbers

# ❌ BAD
await asyncio.sleep(0.1)
timeout = 5.0

# ✅ GOOD
from aidb.common.constants import EVENT_POLL_TIMEOUT_S, CONNECTION_TIMEOUT_S

await asyncio.sleep(EVENT_POLL_TIMEOUT_S)
timeout = CONNECTION_TIMEOUT_S

Reimplementing Utilities

# ❌ BAD
def get_bool_env(name: str, default: bool) -> bool:
    value = os.getenv(name)
    return value.lower() in ("true", "1", "yes") if value else default

# ✅ GOOD
from aidb_common.env import read_bool
result = read_bool("AIDB_TRACE", default=False)

String States

# ❌ BAD
if session_state == "running":
    pass

# ✅ GOOD
from aidb_mcp.core.constants import SessionState
if session_state == SessionState.RUNNING:
    pass

______________________________________________________________________

Quick Discovery

Constants Files

LocationContents
aidb_common/constants.pyLanguage enum, paths, domains
aidb/dap/client/constants.pyDAP events, commands, stop reasons
aidb/common/constants.pyTimeouts (seconds), defaults
aidb_mcp/core/constants.pyMCP tool names, actions
aidb_cli/core/constants.pyIcons, exit codes, Docker

Utility Packages

NeedPackage
JSONaidb_common.io
YAMLaidb_cli.core.yaml (CLI)
Pathsaidb_common.path
Env varsaidb_common.env
Validationaidb_common.validation

Full reference: See docstrings in src/aidb_common/

Search Commands

grep -r "value_to_find" src --include="*.py"
find src -name "constants.py"
grep -r "class.*Enum" src --include="*.py" -l

______________________________________________________________________

When to Create NEW Constants

Only when:

1. Truly new concept - Not covered by existing constants 1. Used 2+ times - Will be reused 1. Proper location - Adding to the RIGHT constants file 1. Following patterns - Matches existing naming conventions

______________________________________________________________________

Enforcement Checklist

Before committing:

  • [ ] No hardcoded URLs (use aidb_common constants)
  • [ ] No hardcoded paths (use path utilities)
  • [ ] No magic numbers for timeouts (use api/constants.py)
  • [ ] No string literals for states (use enums)
  • [ ] No reimplemented utilities (check aidb_common)
  • [ ] No manual env var parsing (use aidb_common.env)

______________________________________________________________________

Resources

  • [Discovery Catalog](resources/discovery-catalog.md) - Complete constants, enums, utilities reference
  • `src/aidb_common/` - Source code with detailed docstrings

Related skills

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.