questioning-hardcoded-values

Question hardcoded literal values in source code to justify their meaning.

1|Updated Oct 17, 2024
One-click install
npx skills add https://github.com/cassamajor/xcnf --skill questioning-hardcoded-values
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: questioning-hardcoded-values
Source: https://github.com/cassamajor/xcnf/tree/main/.claude/skills/questioning-hardcoded-values
Command: npx skills add https://github.com/cassamajor/xcnf --skill questioning-hardcoded-values

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill addresses the ambiguity and potential for bugs introduced by unexplained hardcoded strings, numbers, and assumptions in code, ensuring clarity and maintainability.

Core Features & Use Cases

  • Code Review Enhancement: Provides a systematic approach to questioning literals during code reviews.
  • Documentation Improvement: Guides developers on documenting conventions, defining constants, and verifying assumptions.
  • Use Case: When reviewing code, you encounter if len(data) < 37. This Skill prompts you to ask "What is 37?", leading to the creation of a constant like const ipv6EventSize = 37 with an explanation of its calculation.

Quick Start

Use the questioning-hardcoded-values skill to review the provided code snippet for unexplained literals.

Frequently Asked Questions about questioning-hardcoded-values

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

FAQPage Schema
How do I identify and document magic numbers during a code review?

To identify and document magic numbers during code review, systematically question every hardcoded literal value. Replace unexplained numbers with named constants and document the specific calculation or assumption justifying that exact value.

What is the best way to justify hardcoded values and assumptions in source code?

Justifying hardcoded values in source code involves ensuring every literal answers "why this specific value?" through documented conventions and verified assumptions, replacing ambiguity with clear, maintainable named constants.

How do I review unexplained literal values in a code snippet?

Reviewing unexplained literal values requires scanning the snippet for hardcoded strings and numbers, then prompting the author to define named constants with explanatory documentation to prevent bugs and ensure maintainability.

When do I need to replace hardcoded numbers with named constants?

You need to replace hardcoded numbers with named constants whenever a literal value lacks an immediate explanation, ensuring the calculation or assumption behind the value is verified and documented for future maintainability.

Why should I question hardcoded strings and magic numbers in my code?

Questioning hardcoded strings and magic numbers prevents bugs and improves maintainability by eliminating ambiguity. It ensures unexplained assumptions are verified and documented, making the source code logic clear for future developers.

Does this code review approach work for any programming language?

Yes, this code review approach works for any programming language because questioning hardcoded literal values, defining named constants, and verifying assumptions are universal practices for improving source code quality and maintainability.