aposd-improving-code-clarity
Enforce comments-first workflow for new code and improve naming/documentation for existing code. Use when writing new classes, methods, or functions; when code is 'confusing' or 'hard to understand'; when naming precision is poor; or when variable documentation lacks units, bounds, or ownership. Triggers on: new code, comments-first, naming review, documentation review, not obvious, hard to understand. Produces well-documented code with precise naming, or identifies design problems when comments/names are hard to write.
Best use case
aposd-improving-code-clarity is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Enforce comments-first workflow for new code and improve naming/documentation for existing code. Use when writing new classes, methods, or functions; when code is 'confusing' or 'hard to understand'; when naming precision is poor; or when variable documentation lacks units, bounds, or ownership. Triggers on: new code, comments-first, naming review, documentation review, not obvious, hard to understand. Produces well-documented code with precise naming, or identifies design problems when comments/names are hard to write.
Teams using aposd-improving-code-clarity should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/aposd-improving-code-clarity/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How aposd-improving-code-clarity Compares
| Feature / Agent | aposd-improving-code-clarity | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Enforce comments-first workflow for new code and improve naming/documentation for existing code. Use when writing new classes, methods, or functions; when code is 'confusing' or 'hard to understand'; when naming precision is poor; or when variable documentation lacks units, bounds, or ownership. Triggers on: new code, comments-first, naming review, documentation review, not obvious, hard to understand. Produces well-documented code with precise naming, or identifies design problems when comments/names are hard to write.
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
Related Guides
Best AI Skills for Claude
Explore the best AI skills for Claude and Claude Code across coding, research, workflow automation, documentation, and agent operations.
AI Agents for Coding
Browse AI agent skills for coding, debugging, testing, refactoring, code review, and developer workflows across Claude, Cursor, and Codex.
Cursor vs Codex for AI Workflows
Compare Cursor and Codex for AI coding workflows, repository assistance, debugging, refactoring, and reusable developer skills.
SKILL.md Source
# Skill: aposd-improving-code-clarity ## STOP - The Obviousness Rule **If a code reviewer says your code is not obvious, it is not obvious**—regardless of how clear it seems to you. "Obvious" exists in the reader's mind, not the writer's. **For new code:** Write comments BEFORE implementation. Comment difficulty signals design problems—fix the design, not the comment. --- ## What Counts as "New Code" **Comments-first applies to ALL of these:** | Scenario | Why It's "New Code" | |----------|---------------------| | Writing from scratch | Obviously new | | Copy-paste-modify | New context requires new understanding | | Extending existing function (>5 lines) | Substantial additions need documentation | | Refactoring that changes interfaces | Interface change = new abstraction | | Converting prototype to production | Throwaway code becoming permanent | **Comments-first ALSO applies to:** - Test methods (they're methods too) - Lambda functions with non-trivial logic (>1 expression) - Configuration that defines behavior - Database migrations with business logic **Exemptions (but document why):** - One-liner utility functions with precise names: `def square(x): return x * x` - Trivially obvious getters/setters with no business logic - Character-level bug fixes (`>=` to `>`) - Debug/logging code that will be deleted within 24 hours (mark with `// TEMP:`) --- ## Comments-First Workflow **For new classes/methods, write comments BEFORE implementation:** ``` 1. Write class interface comment (what abstraction it provides) 2. Write interface comments for public methods (signatures + comments, empty bodies) 3. Iterate on comments until structure feels right 4. Write instance variable declarations with comments 5. Fill in method bodies, adding implementation comments as needed 6. New methods discovered during implementation: comment before body 7. New variables: comment at same time as declaration Result: When code is done, comments are also done. ``` ### Why Comments-First Matters | If You Delay | What Happens | |--------------|--------------| | "I'll document after coding" | Documentation often never gets written | | "Code isn't stable yet" | Delay compounds—"even more stable in a few weeks" | | "Just one more feature first" | Backlog grows huge and unattractive | | "I'll find time later" | There is never a convenient time | ### Comment Quality Requirements Comments must meet these criteria or they don't count: | Requirement | Bad Example | Good Example | |-------------|-------------|--------------| | **Describe abstraction** | `# Does the thing` | `# Calculates compound interest with variable rates` | | **Include non-obvious details** | `# Process data` | `# Processes data in chunks to stay under memory limit` | | **Different words than code** | `# Gets user` for `getUser()` | `# Fetches user from cache, falling back to DB` | | **Precision for variables** | `# The count` | `# Number of active connections (0 to MAX_CONN)` | **If your comment just restates the function name, you haven't done comments-first.** --- ## Comment Types | Type | Where | Purpose | Priority | |------|-------|---------|----------| | **Interface** | Declarations | Define abstraction, usage info | Highest—required for every class, variable, method | | **Implementation** | Inside methods | Help understand what code does | Lower—often unnecessary for simple methods | | **"How We Get Here"** | Code paths | Explain conditions under which code runs | Useful for unusual situations | | **Cross-Module** | Dependencies | Describe cross-boundary relationships | Rare but important | ### Comment Levels | Level | Focus | Use For | |-------|-------|---------| | **Precision** (lower) | Exact details: units, bounds, null, ownership | Variable declarations | | **Intuition** (higher) | Reasoning, abstract view, overall intent | Methods, code blocks | --- ## Variable Comment Checklist For each variable, answer these questions in the comment: - [ ] What are the units? (seconds? milliseconds? bytes?) - [ ] Are boundaries inclusive or exclusive? - [ ] What does null mean, if permitted? - [ ] Who owns the resource (responsible for freeing/closing)? - [ ] What invariants always hold? **Goal:** Comment should be complete enough that readers never need to examine all usage sites. --- ## Naming Principles ### Two Required Properties | Property | Requirement | Test | |----------|-------------|------| | **Precision** | Name clearly conveys what entity refers to | "Can someone seeing this name in isolation guess what it refers to?" | | **Consistency** | (1) Always use this name for this purpose (2) Never use it for other purposes (3) All instances have same behavior | Check all usages | ### Naming Procedure ``` 1. Name Evaluation Test: "If someone sees this name without declaration or context, how closely can they guess what it refers to?" 2. Precision Check: - Could this name refer to multiple things? → Too vague - Does this name imply narrower usage than actual? → Too specific - Target: name matches actual scope exactly 3. Consistency Check: - Is this name used everywhere for this purpose? - Is this name used ONLY for this purpose? - Do all variables with this name behave identically? ``` --- ## Common Naming Mistakes | Mistake | Example | Fix | |---------|---------|-----| | Vague status words | `blinkStatus` | `cursorVisible` (predicate showing true/false meaning) | | Too generic | `getCount()` | `numActiveIndexlets` | | Too specific | `delete(Range selection)` | `delete(Range range)` if method works on any range | | Similar names for different things | `socket` vs `sock` | Distinct, descriptive names | | Type in name | `strName` | Just `name` (IDEs show types) | | Repeating class in variable | `File.fileBlock` | `File.block` (context is clear) | --- ## Red Flags | Red Flag | Symptom | What It Signals | |----------|---------|-----------------| | **Comment Repeats Code** | Same words in comment as in entity name | Comment adds no value—rewrite with different words | | **Hard to Describe** | Difficulty writing simple, complete comment | **Design problem**—fix the design, not the comment | | **Hard to Pick Name** | Can't find simple name that creates clear image | **Design smell**—underlying entity lacks clean design | | **Vague Name** | Name could refer to many things (`status`, `flag`, `data`) | Conveys little information; misuse likely | | **Interface Describes Implementation** | Interface comment must explain internals | Class/method is shallow—abstraction is inadequate | | **Implementation Contaminates Interface** | Interface docs include internal details | Violates separation of concerns | --- ## Interface vs Implementation Comments | Interface Comment | Implementation Comment | |-------------------|------------------------| | Describes externally visible behavior | Describes internal workings | | Defines the abstraction | Helps understand how code works | | Required for every public entity | Optional for simple methods | | What user needs to use it | What maintainer needs to modify it | | **Never include implementation details** | Can reference interface concepts | --- ## Anti-Rationalization Table ### Classic Rationalizations | Tempting Shortcut | Why It Feels Right | Why It's Wrong | |-------------------|-------------------|----------------| | "I'll add comments after" | Code isn't stable yet | Delay compounds; documentation never gets written | | "The code is self-documenting" | Good names exist | Code cannot capture abstractions; comments are the only way | | "This is obvious" | Obvious to you now | You wrote it; first-time readers didn't | | "Comments get out of date" | Maintenance burden | Comments-first keeps them synchronized | | "I know what good names are" | Naming feels intuitive | Intuition fails; use the evaluation test | ### Pressure-Based Rationalizations | Tempting Shortcut | Why It Feels Right | Why It's Wrong | |-------------------|-------------------|----------------| | "Demo in 30 minutes" | Time pressure is real | 5 minutes for comments saves 30 minutes of explanation later | | "Team is blocked waiting" | Social pressure | They'll be MORE blocked debugging undocumented code | | "Senior dev said add docs later" | Authority told me | Authority doesn't override discipline; push back | ### Technical Rationalizations | Tempting Shortcut | Why It Feels Right | Why It's Wrong | |-------------------|-------------------|----------------| | "The type system documents it" | Types are precise | Types show WHAT, not WHY; comments explain intent | | "My PR description covers it" | I'll explain there | PR descriptions aren't in the code; readers won't see them | | "Design doc covers this" | Documentation exists | Design docs drift from code; interface comments stay with code | --- ## Types vs Comments Strong type systems are valuable but don't replace comments: | Types Tell You | Comments Tell You | |----------------|-------------------| | WHAT the signature accepts | WHY this design was chosen | | WHAT the return type is | WHAT invariants must hold | | WHAT constraints the compiler enforces | WHAT the abstraction represents | | Structure | Intent | --- ## Emergency Bypass Criteria Skip comments-first ONLY when ALL of these conditions are true: 1. Production is down RIGHT NOW 2. Users are actively impacted, security breach in progress, OR data loss occurring 3. The fix is minimal (rollback or single-line change) 4. You commit to returning for documentation within 24 hours **If bypassing:** Add TODO marker: `// TODO(YYYY-MM-DD): document - emergency fix for [issue]` --- ## Quick Reference ``` BEFORE writing any new code: 1. COMMENT FIRST - Write interface comment before implementation 2. NAME PRECISELY - Can someone guess what it is in isolation? 3. NAME CONSISTENTLY - Same name everywhere, only for this purpose WHEN commenting existing code: 1. DON'T REPEAT - Use different words than the code 2. PRECISION for variables - Units, bounds, null, ownership, invariants 3. INTUITION for methods - Intent, reasoning, what not how 4. HARD TO DESCRIBE? - Fix the design, not the comment DESIGN SMELL SIGNALS: - Hard to write simple comment → design problem - Hard to pick clear name → design problem - Interface must describe implementation → shallow abstraction ``` --- ## Chain | After | Next | |-------|------| | Comments/naming done | cc-code-layout-and-style (CHECKER) |
Related Skills
aposd-verifying-correctness
Verify code correctness before claiming done or committing. Run 6-dimension checklist: requirements coverage, concurrency safety, error handling, resource management, boundary conditions, and security. Output PASS/FAIL per dimension with final DONE/NOT DONE verdict. Use after implementation as pre-commit gate. Triggers on: is it done, ready to commit, verify correctness, did I miss anything, pre-commit check.
aposd-simplifying-complexity
Simplify complex code through the Error Reduction Hierarchy: Define out > Mask > Aggregate > Crash. Use when code is too complex, has scattered error handling, configuration explosion, or callers doing module work. Produce technique analysis table with gate checks before simplified code. Triggers on: too complex, simplify, scattered errors, configuration proliferation, verbose error handling. Complements cc-defensive-programming with design-level error elimination.
aposd-reviewing-module-design
Evaluate module design using APOSD principles with 40-item checklist. Detect complexity symptoms (change amplification, cognitive load, unknown unknowns), shallow modules, information leakage, pass-through methods, and structural anti-patterns. Produce categorized design review (Critical/Moderate/Observations/Positive). Use when reviewing code, assessing interfaces, during PR review, or evaluating 'is this too complex?' Triggers on: code review, design review, module complexity, interface assessment, PR review, structural analysis.
aposd-optimizing-critical-paths
Optimize performance through mandatory measure-first workflow with 3 stages: MEASURE (gate) -> FUNDAMENTAL FIX -> CRITICAL PATH REDESIGN. Use when code is too slow, laggy, hangs, doesn't scale, has timeouts, OOM errors, or high CPU/memory. Emphasize that simpler code usually runs faster. Triggers on: performance issues, optimization needed, takes forever, profiling. Produces profiling-backed optimization with verified improvement.
aposd-maintaining-design-quality
Enforce strategic programming discipline when modifying existing code. Guide through STOP-ASK-DECIDE-VERIFY workflow with urgency tier assessment (trivial/minor/standard/emergency). Include when NOT to refactor (Chesterton's Fence, performance-critical, no tests) and block tactical shortcuts via anti-rationalization tables. Use when fixing bugs, extending features, or tempted to make quick fixes. Triggers on: modify code, fix bug, extend feature, quick fix, tactical change.
aposd-designing-deep-modules
Enforce Design-It-Twice workflow: generate 2-3 radically different approaches, compare them, then implement. Use when designing modules, APIs, or classes before implementation. Triggers on: design, create class, add module, implement feature, new service, API design, before implementing. Produces structured design document with approaches, comparison table, choice rationale, and depth check.
self-improving-ai
Understanding and using StickerNest's self-improving AI system. Use when the user asks about AI self-improvement, prompt versioning, reflection loops, AI evaluation, auto-tuning prompts, or the AI judge system. Covers AIReflectionService, stores, and the improvement loop.
Microsoft Clarity Automation
Automate user behavior analytics with Microsoft Clarity -- export heatmap data, session metrics, and engagement analytics segmented by browser, device, country, source, and more through the Composio Microsoft Clarity integration.
clarity-gate
Pre-ingestion verification for epistemic quality in RAG systems with 9-point verification and Two-Round HITL workflow
bgo
Automates the complete Blender build-go workflow, from building and packaging your extension/add-on to removing old versions, installing, enabling, and launching Blender for quick testing and iteration.
aqwa-analysis
Integrate with AQWA hydrodynamic software for RAO computation, damping analysis, and coefficient extraction. Use for AQWA file processing, RAO calculation, hydrodynamic coefficient extraction, and pre/post processing workflows.
aptos-expert
Expert on Aptos blockchain, Move language, smart contracts, NFTs, DeFi, and Aptos development. Triggers on keywords aptos, move, blockchain, smart contract, nft, defi, web3, mainnet, testnet, devnet