BosskuAI Coding Best Practices
Use this skill when writing or reviewing code that should be easy to change, hard to misuse, and aligned with the existing codebase. For a correctness review of a PR or diff, use bosskuai-rigorous-code-review.
Operating principles
- Prefer boring, readable code over clever code.
- Follow current repo conventions unless they are clearly harmful.
- Optimize for the three expensive failures: wrong behavior, production breakage, and code that is hard to change.
- For new behavior, bug fixes, and risky refactors: prefer test-first or test-guided work when practical.
- Debug with hypotheses, not random edits.
- Use only the APIs that exist in the language and library versions the project runs. Read that version's docs first (
bosskuai-documentation-lookup).
- Judge each change against how the system really runs: several instances at once (in-memory state, local files, sessions, a cron that runs on each instance), workers and queues, each environment, and the moment of deploy, when old and new code overlap.
What good code looks like
- single-responsibility functions and modules
- explicit side effects and error paths
- meaningful names
- shallow control flow with guard clauses
- no hidden shared mutable state
- validation at system boundaries
- tests or verification that prove the claimed behavior
Common problems to catch
- god functions or objects
- primitive obsession where domain values need stronger types
- boolean traps and unreadable call sites
- swallowed exceptions
- magic values
- copy-paste logic drift
- shotgun surgery across too many files for one behavior
Local decision guide
- local cleanup: one function or module is unclear but isolated
- revamp: the same structural problem repeats across many files
- architecture escalation: boundaries or contracts are the real problem
Load bosskuai-code-revamp or bosskuai-software-architecture when the issue is bigger than a local fix.
Verification bias
- reproduce before fixing when debugging
- add or run the narrowest test that proves the behavior
- re-read the saved diff before declaring success
- call out what could not be verified
- test with the value types and nulls production stores (a money value can arrive as the string "0.01"), and cover the edge cases: empty, zero, negative, boundary, null, wrong type, very long, non-ASCII.
Guardrails
- Do not impose a foreign pattern or abstraction just because it is fashionable.
- Do not add abstraction without repeated need.
- Do not mix a broad refactor into a bug fix unless the user asked for both.
- Do not mirror a bad existing pattern silently; fix proportionally and call it out.
- Do not change a shared function's behavior without finding every caller and every flow that uses it.
Output
Return:
- conventions observed
- findings or improvement opportunities
- whether the change should stay local, become a revamp, or escalate
- testing guidance or verification gaps
References
../../references/checklists/coding-best-practices-checklist.md
../../references/playbooks/coding-best-practices-playbook.md
../../references/checklists/engineering-delivery-checklist.md
../../references/checklists/engineering-quality-bar.md
Quick conventions
- Names: nouns for values, verb-noun for functions (
fetchMarketData, isValidEmail), booleans read as questions (isUserAuthenticated); a one-letter or flag name is a finding.
- Default to returning new objects and arrays instead of mutating inputs; mutate deliberately and say why (for example a hot path over large arrays).
- Await independent calls together (
Promise.all or the language equivalent) instead of one after another.
- Check the HTTP status before parsing a response body and wrap low-level errors with context; do not log and swallow them.
- Check-then-act needs one guard: a transaction with a row lock, an atomic update, or a unique constraint. A separate check followed by a write is a race.
- Comments explain why (a constraint, a trade-off), never what the next line does. Extract magic numbers into named constants with units (
DEBOUNCE_DELAY_MS).
- Query only the columns you need;
SELECT * on a wide table is a finding.
- Tests follow arrange, act, assert, and their names state the behaviour ("returns empty array when no markets match query"), not "works".
- Use one consistent response envelope for an API, validate request bodies against a schema at the boundary, and return field-level validation details with a 422 (400 is for malformed input; see
bosskuai-api-design).
- Parse external responses with a schema: ignore extra fields, reject missing fields and changed types, and never coerce them silently.
Adapted in part from ECC skills/coding-standards (affaan-m/ECC, MIT).
1---2name: bosskuai-coding-best-practices3description: "Use when writing or reviewing code for quality: maintainability, readability, testing expectations, error handling, naming, and best-practice checks that fit repo conventions."4metadata:5 source: https://skillmd.com/skills/wankimmy/bosskuai-coding-best-practices6---78# BosskuAI Coding Best Practices910Use this skill when writing or reviewing code that should be easy to change, hard to misuse, and aligned with the existing codebase. For a correctness review of a PR or diff, use `bosskuai-rigorous-code-review`.1112## Operating principles1314- Prefer boring, readable code over clever code.15- Follow current repo conventions unless they are clearly harmful.16- Optimize for the three expensive failures: wrong behavior, production breakage, and code that is hard to change.17- For new behavior, bug fixes, and risky refactors: prefer test-first or test-guided work when practical.18- Debug with hypotheses, not random edits.19- Use only the APIs that exist in the language and library versions the project runs. Read that version's docs first (`bosskuai-documentation-lookup`).20- Judge each change against how the system really runs: several instances at once (in-memory state, local files, sessions, a cron that runs on each instance), workers and queues, each environment, and the moment of deploy, when old and new code overlap.2122## What good code looks like2324- single-responsibility functions and modules25- explicit side effects and error paths26- meaningful names27- shallow control flow with guard clauses28- no hidden shared mutable state29- validation at system boundaries30- tests or verification that prove the claimed behavior3132## Common problems to catch3334- god functions or objects35- primitive obsession where domain values need stronger types36- boolean traps and unreadable call sites37- swallowed exceptions38- magic values39- copy-paste logic drift40- shotgun surgery across too many files for one behavior4142## Local decision guide4344- local cleanup: one function or module is unclear but isolated45- revamp: the same structural problem repeats across many files46- architecture escalation: boundaries or contracts are the real problem4748Load `bosskuai-code-revamp` or `bosskuai-software-architecture` when the issue is bigger than a local fix.4950## Verification bias5152- reproduce before fixing when debugging53- add or run the narrowest test that proves the behavior54- re-read the saved diff before declaring success55- call out what could not be verified56- test with the value types and nulls production stores (a money value can arrive as the string "0.01"), and cover the edge cases: empty, zero, negative, boundary, null, wrong type, very long, non-ASCII.5758## Guardrails5960- Do not impose a foreign pattern or abstraction just because it is fashionable.61- Do not add abstraction without repeated need.62- Do not mix a broad refactor into a bug fix unless the user asked for both.63- Do not mirror a bad existing pattern silently; fix proportionally and call it out.64- Do not change a shared function's behavior without finding every caller and every flow that uses it.6566## Output6768Return:6970- conventions observed71- findings or improvement opportunities72- whether the change should stay local, become a revamp, or escalate73- testing guidance or verification gaps7475## References7677- `../../references/checklists/coding-best-practices-checklist.md`78- `../../references/playbooks/coding-best-practices-playbook.md`79- `../../references/checklists/engineering-delivery-checklist.md`80- `../../references/checklists/engineering-quality-bar.md`8182## Quick conventions8384- Names: nouns for values, verb-noun for functions (`fetchMarketData`, `isValidEmail`), booleans read as questions (`isUserAuthenticated`); a one-letter or `flag` name is a finding.85- Default to returning new objects and arrays instead of mutating inputs; mutate deliberately and say why (for example a hot path over large arrays).86- Await independent calls together (`Promise.all` or the language equivalent) instead of one after another.87- Check the HTTP status before parsing a response body and wrap low-level errors with context; do not log and swallow them.88- Check-then-act needs one guard: a transaction with a row lock, an atomic update, or a unique constraint. A separate check followed by a write is a race.89- Comments explain why (a constraint, a trade-off), never what the next line does. Extract magic numbers into named constants with units (`DEBOUNCE_DELAY_MS`).90- Query only the columns you need; `SELECT *` on a wide table is a finding.91- Tests follow arrange, act, assert, and their names state the behaviour ("returns empty array when no markets match query"), not "works".92- Use one consistent response envelope for an API, validate request bodies against a schema at the boundary, and return field-level validation details with a 422 (400 is for malformed input; see `bosskuai-api-design`).93- Parse external responses with a schema: ignore extra fields, reject missing fields and changed types, and never coerce them silently.9495Adapted in part from ECC skills/coding-standards (affaan-m/ECC, MIT).