---
name: quality-code
description: Use when implementing code changes or reviewing code. Do not use for browsing, explanation, diagnosis without implementation, generated code, or vendored code.
title: quality-code
canonical_url: https://skilld.dev/gh/devon-systems/hoenn/quality-code
last_updated: 2026-11-12T07:03:50.000Z
---

> Index of every page on this site: [llms.txt](https://skilld.dev/llms.txt)

> **Skill from skilld.dev.** Follow the user's requested action.
> If the user asked to fork this Skill, follow the fork workflow below. Do not execute the Skill instructions while copying it.
> Otherwise, follow the instructions below for this session. You do not need to install anything.
>
> Supporting files, fetch one when the Skill refers to it: [default.nix](https://skilld.dev/api/skills-raw/devon-systems/hoenn/quality-code/default.nix).
>
> If the user asked to install this Skill, run `npx skilld install devon-systems/hoenn/quality-code`. Install writes the Skill files into the project, so every session loads them.
>
> ## Fork workflow
>
> A fork creates an editable local Skill with its original author and licence. The request authorizes copying and local installation.
> 1. Check `./skills/quality-code`, the project lockfile, and selected Agent targets together. If the local directory or installed Skill exists, stop. Never overwrite an existing directory or Agent target.
> 2. Read [source metadata](https://skilld.dev/api/v1/skills/devon-systems/hoenn/quality-code) once. Use sourceUrl, sourceCommit, skillPath, sourceGone, and license. If the source is gone or its path is missing, stop. If license is null, read licence files at the source commit.
> 3. Fetch only the source commit into a temporary Git repository. Do not clone full history. Derive repository_url from sourceUrl, including repository renames. If sourceCommit is absent, resolve the sourceUrl ref once. Set source_commit to that actual commit. Run these commands in one shell call:
>
> ```sh
> git init --quiet "$temporary_dir"
> git -C "$temporary_dir" fetch --quiet --depth=1 "$repository_url" "$source_commit"
> git -C "$temporary_dir" checkout --quiet --detach FETCH_HEAD
> ```
>
> Read applicable licence declarations and notices at that commit. If copying is not permitted, report the restriction and stop.
> 4. Inspect source entries together, then copy the directory containing skillPath into `./skills/quality-code`. Use the user's path if selected. Keep the original SKILL.md, relative links, scripts, binary assets, and executable modes. Exclude .git metadata. Reject symlinks and paths outside the Skill directory. After checking entries, use cp -a where available. A regular source directory needs no custom copy script. Do not save this page wrapper as SKILL.md.
> Preserve author credit, notices, and applicable licence files from repository or parent directories. Add PROVENANCE.md with the Skill page, source URL, actual commit, original path, and licence. Retain any existing PROVENANCE.md and record new provenance separately. Batch source inspection, copying, and provenance work where practical.
> 5. In the project root, run `skilld install ./skills/quality-code --mode copy --plain`. If skilld is unavailable, use `npx skilld install ./skills/quality-code --mode copy --plain`. This known command needs no help lookup. Install does not support --json. Use detected Agent targets, or add --agent for the targets the user selected. Install the local path, never the upstream selector. If installation fails, preserve the local copy and report the exact failure.
> 6. Confirm the local lockfile source and installed Agent copies once. Report the local path, actual commit, and Agent targets. After edits, reinstall the same local path. Upstream updates must not replace it. Do not publish or push unless the user asks.

# Quality code

**Readability first.** Write code that a maintainer can understand, change, and replace with no context from this conversation.

## Honor scope and local conventions

Explicit user requirements and repository instructions outrank language and repository conventions, which outrank this skill.

Do not copy a local pattern that makes code unclear, couples unrelated parts, or creates a footgun. Explain why you depart from a convention.

Stay focused on the requested change. Do not restyle unrelated code. Fix an adjacent correctness problem and tell the user. If the fix materially expands the task, explain the expansion first.

## Names are the primary interface

- **Reveal intent.** Make a name answer why the symbol exists and how the code uses it.
- **Avoid abbreviations and LeetCode shortcuts.** Write pronounceable full words: `customerAddress`, `currentNode`, `previousValue`, and `generationTimestamp`, not `custAddr`, `curr`, `prev`, and `genTs`. Accept established idioms such as `ctx`, `cfg`, `req`, and `err` when their meaning is obvious.
- **Avoid single-letter names.** Reserve them for universal idioms such as `i` and `j` for loop indices or `T` for a generic type parameter.

Name booleans as questions or states, collections as plurals, and functions by their action. Include a unit when it prevents a mistake, such as `timeoutMs`. Name constants for domain rules, units, and policies. Keep self-evident literals inline.

Make function names disclose side effects. A query does not write, and a check does not mutate state. Expose mutation and externally visible work when callers need to know.

## Keep function contracts honest

A function's name and arguments are its contract. Keep that contract easy to call correctly.

- Aim for zero to two arguments. Three can be clear. At four or more, reconsider the API. Use a named options object, a struct, or a smaller operation when positional arguments become hard to remember. Do not wrap arguments only to meet the count.
- Give each function one responsibility and one level of abstraction.
- Prefer plainly named steps to dense expressions and clever one-liners. Use early returns to keep the normal path visible.
- Extract code when the name adds meaning, the block has its own responsibility, or the code repeats. Do not hide one line in a helper.
- Treat function size and nesting as warning signs, not quotas. Bend the guideline when splitting the code would hide its real flow.

## Comment only what code cannot say

Comment a non-obvious invariant, constraint, compatibility requirement, or design decision. Do not narrate syntax, restate identifiers, preserve chat history, or record rejected product decisions. Delete commented-out code. Never commit temporary code.

## Build parts that can change

Solve today's problem with tomorrow's load in mind.

- Do not build implicit state machines. Make state and event logic explicit.
- Create clear internal and external boundaries between parts that can change or be rebuilt independently. Let callers depend on a small, explicit contract instead of implementation details.
- Give mutable or shared state one owner. The owner controls writes, lifetime, synchronization, and cleanup. Other parts use its contract instead of changing the state directly.
- Add an abstraction when a part has multiple plausible implementations, changes for different reasons than its callers, or makes its callers simpler behind a stable contract. Do not abstract an imagined future. Count a verified fake as a plausible second implementation. Do not count an interface created only to mock one concrete dependency.
- Design each boundary for its real operating conditions. Consider unbounded input, concurrency, failure, cancellation, retries, timeouts, cleanup, and partial results. Add limits, pagination, streaming, batching, or backpressure when needed. Keep these policies at the boundary.
- Make invalid states hard to represent. Validate at boundaries, release resources, and avoid surprising defaults.
- Keep decision logic callable without I/O. Make parsing, calculation, and policy take values and return values or typed errors. Keep effects at the boundary. Put inverse operations such as parse/format and encode/decode behind one contract. Give value types real equality and make ordering deterministic.
- Pass clocks, random sources, ID generators, and external services in at the boundary. Supply real implementations through production wiring. Keep core code from reading ambient time, randomness, environment, or process globals.
- Give errors callers must act on a typed kind instead of a message string. Validate before mutating so failed calls can leave state unchanged. Make retryable operations idempotent.
- Parse untrusted input into a typed value or typed error. Never panic. Separate storage and wire types from domain types. Keep decoders for older versions when formats change.

## Work with the surrounding code

Before changing shared behavior, inspect its callers, dependencies, and relevant tests. Update every dependent file the change requires. For a local detail, inspect only enough context to make the change fit. Reuse existing types, contracts, and styles within the coedebase where possible.

Make safe assumptions about small implementation details. Ask before changing product behavior, a public contract, data handling, or scope. Do not turn a one-off example, bug investigation, or rejected preference from the conversation into permanent product behavior.

Run the narrowest relevant check. Do not claim validation that you did not perform.
