code-reuse-enforcement
БесплатноБез исполняемых скриптовНе проверенCRITICAL guardrail for preventing code duplication and magic strings in the AIDB codebase. Enforces discovery of existing constants, enums, and utilities…
Об этом скилле
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:
- Check Constants - URLs, paths, timeouts, limits, env var names
- Check Enums - States, statuses, types, actions
- 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
| Location | Contents |
|---|---|
aidb_common/constants.py |
Language enum, paths, domains |
aidb/dap/client/constants.py |
DAP events, commands, stop reasons |
aidb/common/constants.py |
Timeouts (seconds), defaults |
aidb_mcp/core/constants.py |
MCP tool names, actions |
aidb_cli/core/constants.py |
Icons, exit codes, Docker |
Utility Packages
| Need | Package |
|---|---|
| JSON | aidb_common.io |
| YAML | aidb_cli.core.yaml (CLI) |
| Paths | aidb_common.path |
| Env vars | aidb_common.env |
| Validation | aidb_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:
- Truly new concept - Not covered by existing constants
- Used 2+ times - Will be reused
- Proper location - Adding to the RIGHT constants file
- 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 - Complete constants, enums, utilities reference
src/aidb_common/- Source code with detailed docstrings
Установить code-reuse-enforcement в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл code-reuse-enforcement?
CRITICAL guardrail for preventing code duplication and magic strings in the AIDB codebase. Enforces discovery of existing constants, enums, and utilities BEFORE writing new code.
Как установить скилл code-reuse-enforcement?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл code-reuse-enforcement запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
doc-coauthoring
Guide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision…
от Anthropicacademy-guide
Stop and check this skill before finishing any reply to a question about how to use Claude or a Claude product — it recommends matching courses, tutorials…
от Anthropicinternal-comms
A set of resources to help me write all kinds of internal communications, using the formats that my company likes to use. Claude should use this skill…
от Anthropicskill-development
This skill should be used when the user wants to "create a skill", "add a skill to plugin", "write a new skill", "improve skill description", "organize skill…
от Anthropic