agentleFS
dominionthedevdominionthedev/skills/advanced-coding/SKILL.md

advanced-coding

Skill1 starsChanged 6 months agoMITView on GitHub

Expert-level coding skill for Go, Python, and Rust. Use this skill whenever the user asks to write, review, refactor, debug, optimize, or architect code in Go, Python, or Rust. Triggers on: writing functions/structs/modules, CLI tools, systems programming, concurrency, performance optimization, error handling, testing, API design, data pipelines, async code, memory safety, generics, type systems, and idiomatic patterns in any of these three languages. Also triggers when comparing these languages, porting code between them, or discussing trade-offs. Don't wait to be explicitly asked — proactively use this skill whenever Go, Python, or Rust code quality matters.

The file

We split this skill into the rules it gives an agent

12 rules. About 0 are common, 3 are distinctive, and 9 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈3

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 9

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Use errors.Is / errors.As for error inspection.

    line 35
  2. Very specific:

    Prefer table-driven tests with t.Run

    line 36
  3. Very specific:

    Use context.Context as the first argument in all I/O and long-running functions

    line 37
  4. Very specific:

    Prefer slog for structured logging (Go 1.21+)

    line 41
  5. Very specific:

    Use errgroup for concurrent goroutine fan-out with error collection

    line 42
  6. Very specific:

    Use pathlib.Path not os.path

    line 74
  7. Very specific:

    Use logging not print; configure with logging.config.dictConfig

    line 78
  8. Very specific:

    Use thiserror for library errors, anyhow for application errors

    line 112
  9. Very specific:

    Prefer impl Trait in function args, -> impl Trait in return when one type.

    line 113
  10. Distinctive:

    Prefer iterators + adapters over manual loops.

    line 117
  11. Distinctive:

    When porting between languages, read the relevant reference file:

    line 179
  12. Distinctive:

    Before presenting code, verify:

    line 188

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “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

Advanced Coding — Go · Python · Rust

You are an expert engineer in Go, Python, and Rust. Write code that is production-grade, idiomatic, and battle-tested. No toy examples. No hand-waving. No half-measures.


Core Principles (all languages)

  • Write what's needed — no over-engineering, no premature abstraction
  • Error paths are first-class — never ignore errors; handle or propagate explicitly
  • Performance is a feature — choose the right data structure, algorithm, and memory strategy
  • Tests are part of the code — write them unless explicitly asked not to
  • Idiomatic > clever — readable, maintainable code beats terse tricks
  • Comments explain WHY, not WHAT — code should be self-explanatory

Go

Patterns to follow

  • Use errors.Is / errors.As for error inspection; wrap with fmt.Errorf("context: %w", err)
  • Prefer table-driven tests with t.Run
  • Use context.Context as the first argument in all I/O and long-running functions
  • Interfaces belong in the consumer package, not the implementor
  • Struct embedding for behavior composition, not deep inheritance trees
  • sync.Pool for frequently-allocated objects under load
  • Prefer slog for structured logging (Go 1.21+)
  • Use errgroup for concurrent goroutine fan-out with error collection

Project layout (standard)

cmd/
  myapp/main.go        # entry point; thin, wires dependencies
internal/
  domain/              # core types & logic
  infra/               # DB, HTTP, messaging adapters
pkg/                   # re-usable exported packages

Common pitfalls to avoid

  • Goroutine leaks: always ensure goroutines can exit (context cancellation / done channel)
  • Nil map write panics: make(map[K]V) before writing
  • Loop variable capture in goroutines: copy or use range val (Go 1.22+)
  • Interface nil trap: typed nil ≠ nil interface

Concurrency checklist

  • Channel directions typed (chan<-, <-chan)
  • Select default case to prevent blocking
  • WaitGroup Add before spawning goroutine
  • Mutex protects data, not code blocks

Python

Patterns to follow

  • Type-annotate everything (use from __future__ import annotations for forward refs)
  • dataclasses or pydantic for structured data; avoid raw dicts as domain types
  • Async: use asyncio + anyio for structured concurrency; avoid asyncio.gather raw
  • Use pathlib.Path not os.path
  • contextlib.contextmanager / asynccontextmanager for resource management
  • Protocols for duck-typing without inheritance
  • __slots__ for perf-critical, frequently-instantiated classes
  • Use logging not print; configure with logging.config.dictConfig

Toolchain (opinionated)

PurposeTool
Package managementuv (preferred) or poetry
Linting/formattingruff
Type checkingmypy --strict or pyright
Testingpytest + pytest-asyncio
HTTP clienthttpx
CLItyper
Configpydantic-settings

Async patterns

# Structured concurrency — prefer over raw gather
async with asyncio.TaskGroup() as tg:
    task_a = tg.create_task(fetch_a())
    task_b = tg.create_task(fetch_b())
# Both results available, exceptions propagated cleanly

Common pitfalls to avoid

  • Mutable default arguments: def f(items: list = None) → use None and assign inside
  • Late binding closures in loops: capture with default arg or functools.partial
  • Shadowing builtins: never name variables list, id, type, input, etc.
  • except Exception swallowing: always log or re-raise; never silent swallow

Rust

Patterns to follow

  • Model invalid state as unrepresentable via the type system
  • Use thiserror for library errors, anyhow for application errors
  • Prefer impl Trait in function args, -> impl Trait in return when one type; use generics when multiple callers need different types
  • Newtype pattern to enforce domain invariants: struct UserId(u64)
  • Builder pattern for structs with many optional fields
  • #[must_use] on functions returning Result / important values
  • Prefer iterators + adapters over manual loops; trust the optimizer
  • tokio for async runtime; axum for HTTP; sqlx for async DB
  • Try using zig(if available) cc, clang, etc when needed

Ownership mental model (quick ref)

  • Move semantics by default — if you need reuse, clone or borrow
  • &T for read-only borrow, &mut T for exclusive mutation
  • Lifetime annotations only when the compiler asks — don't over-annotate
  • Arc<Mutex<T>> for shared mutable state across threads; Rc<RefCell<T>> for single-thread

Error handling

// Library: define your errors
#[derive(Debug, thiserror::Error)]
pub enum AppError {
    #[error("database error: {0}")]
    Db(#[from] sqlx::Error),
    #[error("not found: {0}")]
    NotFound(String),
}

// Application: use anyhow for ergonomic ?-chaining
fn run() -> anyhow::Result<()> {
    let conn = connect().context("failed to connect to DB")?;
    Ok(())
}

Performance checklist

  • cargo build --release for benchmarks
  • Profile with cargo flamegraph or perf before optimizing
  • Avoid .clone() in hot paths — audit with cargo clippy
  • Use BufReader / BufWriter for I/O
  • SmallVec / tinyvec for small collections that usually stay small
  • SIMD via std::simd or packed_simd2 only after profiling proves it's needed

Async patterns

// Spawn concurrent tasks with join!
let (a, b) = tokio::join!(fetch_a(), fetch_b());

// Fan-out with error handling
let handles: Vec<_> = items.iter().map(|i| tokio::spawn(process(i))).collect();
let results: Vec<_> = futures::future::try_join_all(handles).await?;

Language Selection Guide

NeedReach for
Fast iteration, data work, scripting, MLPython
Network services, CLIs, DevOps toolingGo
Systems, performance-critical, memory safetyRust
Embedding in other systems, WASMRust
Rapid API serverGo or Python (FastAPI)

Cross-language: porting patterns

When porting between languages, read the relevant reference file:

  • Go ↔ Rust patterns: references/go-rust.md
  • Python ↔ Go patterns: references/python-go.md
  • Python ↔ Rust (PyO3): references/python-rust.md

Code Review Checklist

Before presenting code, verify:

  • All error paths handled
  • No panics / unchecked unwraps in library code
  • No unbounded memory growth under load
  • Secrets/configs from env, not hardcoded
  • Graceful shutdown implemented for servers
  • Tests cover the happy path and at least 2 failure modes

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.