code-quality

Pragmatic coding standards and code review guidelines. Covers naming, functions, anti-patterns, review checklists, and AI-specific review patterns. Replaces clean-code + code-review-checklist.

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "code-quality" with this command: npx skills add tai-ch0802/skills-bundle/tai-ch0802-skills-bundle-code-quality

Code Quality — Standards & Review

CRITICAL SKILL — Be concise, direct, and solution-focused.


Core Principles

PrincipleRule
SRPSingle Responsibility — each function/class does ONE thing
DRYDon't Repeat Yourself — extract duplicates, reuse
KISSKeep It Simple — simplest solution that works
YAGNIYou Aren't Gonna Need It — don't build unused features
Boy ScoutLeave code cleaner than you found it

Naming Rules

ElementConvention
VariablesReveal intent: userCount not n
FunctionsVerb + noun: getUserById() not user()
BooleansQuestion form: isActive, hasPermission, canEdit
ConstantsSCREAMING_SNAKE: MAX_RETRY_COUNT

Rule: If you need a comment to explain a name, rename it.


Function Rules

RuleDescription
SmallMax 20 lines, ideally 5-10
One ThingDoes one thing, does it well
One LevelOne level of abstraction per function
Few ArgsMax 3 arguments, prefer 0-2
No Side EffectsDon't mutate inputs unexpectedly

Code Structure

PatternApply
Guard ClausesEarly returns for edge cases
Flat > NestedAvoid deep nesting (max 2 levels)
CompositionSmall functions composed together
ColocationKeep related code close

Code Review Checklist

Correctness

  • Code does what it's supposed to do
  • Edge cases handled
  • Error handling in place
  • No obvious bugs

Security

  • Input validated and sanitized
  • No SQL/NoSQL injection vulnerabilities
  • No XSS or CSRF vulnerabilities
  • No hardcoded secrets or sensitive credentials
  • AI-Specific: Protection against Prompt Injection (if applicable)
  • AI-Specific: Outputs are sanitized before being used in critical sinks

Performance

  • No N+1 queries
  • No unnecessary loops
  • Appropriate caching
  • Bundle size impact considered

Testing

  • Unit tests for new code
  • Edge cases tested
  • Tests readable and maintainable

Documentation

  • Complex logic commented
  • Public APIs documented
  • README updated if needed

AI & LLM Review Patterns (2025)

Logic & Hallucinations

  • Chain of Thought: Does the logic follow a verifiable path?
  • Edge Cases: Did the AI account for empty states, timeouts, and partial failures?
  • External State: Is the code making safe assumptions about file systems or networks?

Prompt Engineering Review

// ❌ Vague prompt in code
const response = await ai.generate(userInput);

// ✅ Structured & Safe prompt
const response = await ai.generate({
  system: "You are a specialized parser...",
  input: sanitize(userInput),
  schema: ResponseSchema
});

Anti-Patterns

❌ Pattern✅ Fix
Comment every lineDelete obvious comments
Helper for one-linerInline the code
Factory for 2 objectsDirect instantiation
utils.ts with 1 functionPut code where used
"First we import..."Just write code
Deep nestingGuard clauses
Magic numbersNamed constants
God functionsSplit by responsibility
any typeProper types
Long functions (100+ lines)Small, focused functions

Review Comments Guide

// Blocking issues use 🔴
🔴 BLOCKING: SQL injection vulnerability here

// Important suggestions use 🟡
🟡 SUGGESTION: Consider using useMemo for performance

// Minor nits use 🟢
🟢 NIT: Prefer const over let for immutable variable

// Questions use ❓
❓ QUESTION: What happens if user is null here?

AI Coding Style

SituationAction
User asks for featureWrite it directly
User reports bugFix it, don't explain
No clear requirementAsk, don't assume

🔴 Before Editing ANY File (THINK FIRST!)

QuestionWhy
What imports this file?They might break
What does this file import?Interface changes
What tests cover this?Tests might fail
Is this a shared component?Multiple places affected

🔴 Rule: Edit the file + all dependent files in the SAME task. 🔴 Never leave broken imports or missing updates.


🔴 Self-Check Before Completing (MANDATORY)

CheckQuestion
Goal met?Did I do exactly what user asked?
Files edited?Did I modify all necessary files?
Code works?Did I test/verify the change?
No errors?Lint and TypeScript pass?
Nothing forgotten?Any edge cases missed?

🔴 Rule: If ANY check fails, fix it before completing.


Summary

DoDon't
Write code directlyWrite tutorials
Let code self-documentAdd obvious comments
Fix bugs immediatelyExplain the fix first
Inline small thingsCreate unnecessary files
Name things clearlyUse abbreviations
Keep functions smallWrite 100+ line functions

Remember: The user wants working code, not a programming lesson.

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

Coding

python-patterns

No summary provided by upstream source.

Repository SourceNeeds Review
Coding

game-development

No summary provided by upstream source.

Repository SourceNeeds Review
Coding

code-review-checklist

No summary provided by upstream source.

Repository SourceNeeds Review
Coding

gemini-api-dev

No summary provided by upstream source.

Repository SourceNeeds Review