agentleFS
vndeevndee/engineering-skills/.claude/skills/code-quality/SKILL.md

code-quality

Skill3 starsChanged 8 months agoMITView on GitHub

Use when writing any production code in Go, Python, or React — enforces performance-first patterns, prevents N+1 queries, demands algorithmic efficiency, and ensures security safety at every layer

38 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use spring-boot, design-patterns and 9 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • MindrallySkill

    spring-boot

    Expert guidance for Spring Boot application development with best practices for RESTful APIs, testing, security, and deployment

    Also in 3 projects that use this

  • ratacatSkill

    design-patterns

    Use when designing software architecture, refactoring code structure, solving recurring design problems, or when code exhibits symptoms like tight coupling, rigid hierarchies, scattered responsibilities, or difficult-to-test components. Also use when choosing between architectural approaches or reviewing code for structural improvements.

    Also in 3 projects that use this

  • rogue-dev-studioSkill

    python

    Python 3.13 with uv package manager via mise. Use when the project needs this capability or the user / team manifest asks for it. Use for specialized `python` work when listed in TEAM.yaml or explicitly requested.

    Also in 3 projects that use this

  • BlockSkill

    debugging

    Debugging guidelines and best practices

    Also in 3 projects that use this

  • Microsoft AzureSkill

    git-workflow

    Squad branching model: dev-first workflow with insiders preview channel

    Also in 3 projects that use this

  • NVIDIASkill

    testing

    Run Python and Rust tests for physicsnemo-curator using uv + pytest with coverage reporting via pytest-cov, and cargo-nextest for Rust tests. Includes benchmark workflows with pytest-benchmark and criterion.

    Also in 3 projects that use this

The file

We split this skill into the rules it gives an agent

6 rules. 0 are common, 4 are distinctive, and 2 are very specific to this project.

  • 0

    Common

    Most of the 37 edited versions we read keep these.

  • 4

    Distinctive

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Every line of code must be written with performance and scalability in mind.

    line 10
  2. Distinctive:

    Before performance even matters, the code must be safe:

    line 18
  3. Very specific:

    If security is missing, the code doesn't ship.

    line 27
  4. Very specific:

    Every WHERE, JOIN ON, and ORDER BY column in queries that operate on large tables MUST have an index.

    line 70
  5. Distinctive:

    Before writing any data processing logic, state the complexity:

    line 188
  6. Distinctive:

    Before considering any code complete, verify:

    line 239

“Common” is measured: kept by at least 6 in 10 of the 37 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Code Quality & Performance Standards

Overview

Every line of code must be written with performance and scalability in mind. No naive implementations. No "fix it later." Write it right the first time.

Core principle: Think like a competitive programmer — analyze time/space complexity before writing. O(n) where O(n^2) exists is a bug, not a TODO. Security is not a feature — it's a baseline.

The Non-Negotiables

0. Security Safety — The Baseline

Before performance even matters, the code must be safe:

  • Parameterized queries ALWAYS — never concatenate user input into SQL. Use $1, $2 (pgx) or :param (SQLAlchemy). No exceptions.
  • Input validation at every boundary — ValidateBody[T] (Go), Pydantic models (Python). Never trust user input.
  • Auth middleware on protected routes — every endpoint that accesses user data must verify authentication.
  • No hardcoded secrets — API keys, passwords, JWT secrets come from environment variables.
  • No sensitive data in logs — never log passwords, tokens, or PII.
  • CORS, security headers, rate limiting — applied at middleware level from day one.

If security is missing, the code doesn't ship. Period. See security skill for full patterns.

These patterns are never acceptable in production code:

1. N+1 Queries — The Cardinal Sin

// NEVER: N+1 query — O(n) database roundtrips
for _, user := range users {
    posts, _ := postRepo.GetByUserID(ctx, user.ID)
    user.Posts = posts
}

// ALWAYS: Batch query — O(1) database roundtrips
posts, _ := postRepo.GetByUserIDs(ctx, userIDs)
postsByUser := groupBy(posts, func(p Post) uuid.UUID { return p.UserID })
# NEVER: N+1 in SQLAlchemy
users = await session.execute(select(UserModel))
for user in users:
    posts = user.posts  # lazy load = N queries

# ALWAYS: Eager load
stmt = select(UserModel).options(selectinload(UserModel.posts))

# Or batch query
stmt = select(PostModel).where(PostModel.user_id.in_(user_ids))

2. Unbounded Queries

// NEVER: select all rows
rows, _ := pool.Query(ctx, "SELECT * FROM events")

// ALWAYS: paginate with limit/offset, enforce max limit
query := "SELECT * FROM events WHERE org_id = $1 ORDER BY created_at DESC LIMIT $2 OFFSET $3"

3. Missing Indexes

Every WHERE, JOIN ON, and ORDER BY column in queries that operate on large tables MUST have an index. When adding a query, verify the index exists or create a migration.

-- Check before shipping
EXPLAIN ANALYZE SELECT * FROM events WHERE user_id = $1 ORDER BY created_at DESC;
-- If you see "Seq Scan" on a large table, add an index

4. Inefficient Data Structures

// NEVER: O(n) lookup in a loop = O(n*m)
for _, item := range items {
    for _, allowed := range allowedIDs {
        if item.ID == allowed { ... }
    }
}

// ALWAYS: O(1) lookup = O(n)
allowedSet := make(map[uuid.UUID]struct{}, len(allowedIDs))
for _, id := range allowedIDs {
    allowedSet[id] = struct{}{}
}
for _, item := range items {
    if _, ok := allowedSet[item.ID]; ok { ... }
}
# NEVER: O(n) membership test
if user_id in user_id_list:  # list = O(n)

# ALWAYS: O(1) membership test
if user_id in user_id_set:  # set = O(1)

5. Redundant Allocations

// NEVER: allocate in hot loop
for _, item := range items {
    result := make([]byte, 0) // allocation per iteration
    // ...
}

// ALWAYS: pre-allocate with known capacity
results := make([]Response, 0, len(items))
for _, item := range items {
    results = append(results, mapToResponse(item))
}

Database Performance Patterns

Batch Operations

// NEVER: insert one at a time
for _, user := range users {
    _, err := pool.Exec(ctx, "INSERT INTO users (...) VALUES (...)", ...)
}

// ALWAYS: batch insert
batch := &pgx.Batch{}
for _, user := range users {
    batch.Queue("INSERT INTO users (...) VALUES (...)", ...)
}
results := pool.SendBatch(ctx, batch)
defer results.Close()

Count + Items in One Repo Call

// ALWAYS: repo returns (items, total, error) for list endpoints
func (r *repo) List(ctx context.Context, limit, offset int) ([]Item, int, error) {
    // Count query
    var total int
    err := r.pool.QueryRow(ctx, "SELECT COUNT(*) FROM items WHERE ...").Scan(&total)
    // Items query (same WHERE clause)
    rows, err := r.pool.Query(ctx, "SELECT ... FROM items WHERE ... LIMIT $1 OFFSET $2", limit, offset)
    return items, total, nil
}

Atomic Operations (Transactions)

// When multiple writes must succeed or fail together
tx, _ := pool.Begin(ctx)
defer tx.Rollback(ctx)
// ... multiple operations ...
tx.Commit(ctx)

Query Building

// Dynamic WHERE clauses: build conditions array, use parameterized position args
var conditions []string
var args []interface{}
argPos := 1

conditions = append(conditions, fmt.Sprintf("org_id = $%d", argPos))
args = append(args, orgID)
argPos++

if search != "" {
    conditions = append(conditions, fmt.Sprintf("name ILIKE $%d", argPos))
    args = append(args, "%"+pkg.EscapeLikePattern(search)+"%")
    argPos++
}

whereClause := strings.Join(conditions, " AND ")

Algorithm Standards

Before writing any data processing logic, state the complexity:

AcceptableUnacceptable
O(n) single passO(n^2) nested loops on same data
O(n log n) sort then binary searchO(n) linear search in a loop
O(1) hash map lookupO(n) list scan for membership
O(n) with pre-computed mapO(n*m) cross-product without index
Streaming/chunked for large dataLoading everything into memory

Concurrency Patterns

// When you have independent I/O calls, parallelize
g, ctx := errgroup.WithContext(ctx)
var users []User
var stats Stats

g.Go(func() error {
    var err error
    users, err = userRepo.List(ctx)
    return err
})
g.Go(func() error {
    var err error
    stats, err = statsService.Get(ctx)
    return err
})
if err := g.Wait(); err != nil {
    return err
}
# Python: asyncio.gather for independent I/O
users, stats = await asyncio.gather(
    user_repo.list(),
    stats_service.get(),
)

React Performance

  • Virtualize long lists (>100 items) — use @tanstack/react-virtual
  • Debounce search inputs — don't fire API on every keystroke
  • Paginate API calls — never fetch unbounded lists
  • Memoize expensive computations — but only when profiler confirms the cost
  • Code split routes — React.lazy for route-level splitting

Self-Review Checklist

Before considering any code complete, verify:

  • No N+1 queries — every related data load is batched or joined
  • All list queries have LIMIT — no unbounded selects
  • WHERE/JOIN columns are indexed — checked with EXPLAIN ANALYZE
  • No O(n^2) when O(n) or O(n log n) is possible
  • Pre-allocated slices/arrays with known capacity
  • Independent I/O calls are parallelized (errgroup / asyncio.gather)
  • Batch inserts/updates for multiple rows
  • Transactions for multi-write operations that must be atomic
  • No redundant allocations in hot paths
  • Search queries use proper escaping (LIKE patterns)

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.