magic-value-elimination

Replace magic values with named constants and enums in Python, TypeScript, and Go.

28|3|Updated Feb 22, 2026
One-click install
npx skills add https://github.com/oborchers/fractional-cto --skill magic-value-elimination
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: magic-value-elimination
Source: https://github.com/oborchers/fractional-cto/tree/main/pedantic-coder/skills/magic-value-elimination
Command: npx skills add https://github.com/oborchers/fractional-cto --skill magic-value-elimination

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill eliminates "magic values" (unexplained numbers, strings, or booleans) in code, making it more readable, maintainable, and less prone to errors.

Core Features & Use Cases

  • Identify and Replace Magic Numbers: Replaces unexplained numeric literals with named constants.
  • Enforce Named Constants for Strings: Ensures string literals representing statuses, types, or categories are replaced with enums or named constants.
  • Use Case: Reviewing a codebase, you find if elapsed > 86400:. This Skill helps transform it into if elapsed > SECONDS_PER_DAY: for clarity.

Quick Start

Review the provided Python code snippet for any magic values and suggest replacements with named constants or enums.

Frequently Asked Questions about magic-value-elimination

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I eliminate magic numbers and unexplained literals in my code?

To eliminate magic numbers and unexplained literals, replace them with named constants or enums. This process transforms values like `86400` into `SECONDS_PER_DAY`, enforcing the DRY principle and improving code clarity and maintainability.

What is a magic value in programming and when should I replace it?

A magic value is an unexplained numeric literal, string literal used for statuses, or ambiguous boolean parameter. You should replace magic values with named constants or enums when they reduce code readability and obscure the intent of conditional logic.

How do I replace string literals used for statuses and types with enums?

Replace string literals used for statuses and types by extracting them into named constants or enums. This enforces the DRY principle for values across your codebase, ensuring string statuses are clearly defined and preventing typos.

Does magic value elimination work with Python, TypeScript, and Go?

Yes, magic value elimination works with Python, TypeScript, and Go. It addresses common anti-patterns like "obvious numbers" and "only used once" literals across these languages by replacing them with appropriate named constants and enums.

What is the best way to handle ambiguous boolean parameters in function calls?

The best way to handle ambiguous boolean parameters is to replace them with named constants or enums. Eliminating ambiguous booleans clarifies function arguments, transforming unclear true or false values into explicitly named configuration states.