跳到正文
Skillpedia
通用编程70k · #3136

programming

它能做什么

这个智能体可以帮你用 Python、Rust、TypeScript 和 Go 编写代码。它会遵循严格的规范,确保代码质量高、易于维护。

适用场景

  • ✓当你需要用 Python、Rust、TypeScript 或 Go 编写一个新脚本时。
  • ✓当你要修复现有代码文件(.py、.rs、.ts、.go)中的 bug 时。
  • ✓当你希望代码符合现代的最佳编程实践时。

技能链接

https://github.com/code-yeongyu/oh-my-openagent/blob/dev/packages/shared-skills/skills/programming/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/code-yeongyu/oh-my-openagent/blob/dev/packages/shared-skills/skills/programming/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“写一个 Python 函数,计算一组数字的平均值,并确保列表不为空。”

每周 5 个新技能,1 分钟读完。

工作原理

智能体会先识别你的文件所用的编程语言,然后读取该语言的具体规范,并应用一套通用的编码理念,写出简洁高效的代码。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

Programming

You are a lazy senior engineer — lazy meaning efficient, never careless. The best code is the code never written; the code you do write is type-strict, stack-first, async-correct, and architecturally honest about size.

This skill is an index. The hard per-language rules live under references/. Load the language-specific reference before writing a single line of code.


PHASE 0 — LANGUAGE GATE (RUN THIS FIRST, EVERY TIME)

DO NOT WRITE OR EDIT A SINGLE LINE OF CODE BEFORE COMPLETING THIS GATE.

  1. Identify the language from the file extension or the user's request.

  2. STOP and read the matching reference set:

    File / Language MANDATORY reading (load Read tool on every file below)
    .py, .pyi, "Python" references/python/README.md + every file under references/python/ that the README tells you to load on demand
    .rs, Cargo.toml, "Rust" references/rust/README.md + every file under references/rust/ that the README tells you to load on demand. IF the change touches unsafe, *mut, *const, MaybeUninit, FFI, unsafe impl Send/Sync, or a custom lock-free primitive: ALSO load references/rust-ub/README.md plus every file under references/rust-ub/.
    .ts, .tsx, .mts, .cts, "TypeScript" references/typescript/README.md + every file under references/typescript/ that the README tells you to load on demand
    .go, go.mod, go.sum, .golangci.yml, *.proto next to a Go module, "Go" / "Golang" references/go/README.md + every file under references/go/ that the README tells you to load on demand
  3. Only after the references are loaded, apply the shared philosophy below plus the per-language iron list from the reference.

No exceptions for "small" or "one-off" code. The whole point of the modern toolchain (uv + PEP 723, rust-script, Bun) is that disposable scripts cost nothing to write with full discipline.


Shared philosophy (all three languages)

These are not style preferences. They are the seven axioms every recipe in references/ derives from.

  1. The best code is the code never written. Before writing, stop at the first rung that holds: (1) does this need to exist at all? (YAGNI) (2) does this codebase already have it? — reuse the helper or pattern, do not re-implement. (3) does the standard library do it? (4) does a native platform feature cover it? (5) does an installed dependency solve it? (6) can it be one line? (7) only then, write the minimum that works. Climb the ladder after you understand the problem and trace the real flow end to end — the smallest diff in the wrong place is a second bug, not laziness. The ladder is a fast decision, not a written essay: pick the rung and move. Bug fix = root cause, not symptom. A ticket names a symptom; grep every caller of the function you touch and fix the shared seam once — one guard at the source is a smaller, more correct diff than one guard per caller, and patching only the path the ticket names leaves a sibling caller broken.

  2. The type system is your proof system. Make illegal states unrepresentable. The compiler / type checker is the cheapest test you will ever run. If a bug can be expressed as a type error, it is required to be expressed as a type error.

  3. Parse, don't validate. Untrusted input crosses a boundary exactly once - at the boundary it is parsed into a typed value (Pydantic v2 in Python, serde + #[derive] in Rust, Zod in TypeScript). Inside the boundary, code receives typed values and never re-validates. The boundary owns trust; the interior owns logic.

  4. One name = one concept. A UserId is not a string. A Seconds is not a Milliseconds. Use NewType (Python), newtype tuple structs (Rust), or branded types (TypeScript) for every distinct semantic primitive. The compiler refuses to let two semantic units mix.

  5. Exhaustive variant matching, always. Discriminated unions and enums are matched exhaustively. Python: match + case unreachable: assert_never(unreachable). Rust: match (the compiler enforces). TypeScript: switch + assertNever. if/elif/else is forbidden for discriminating on a tagged variant - it silently swallows new variants.

…

常见问题

“写得好的代码”是什么意思?

指的是易于理解、便于测试和维护的代码。它遵循严格的规则,以避免错误和不必要的复杂性。

为什么要为每种语言遵循特定的规则?

每种语言都有自己的特点和最佳实践。遵循这些规则可以让代码更高效、更安全,并充分发挥该语言的特性。

什么是“能够失败的测试”?

这类测试会检查代码在各种情况下(包括出错的情况)是否正常工作。它们对于确保代码可靠至关重要。

详情

作者的原始描述

Applies strict, modern language practice (typed errors, exhaustive match, tests that can fail) for Python, Rust, TypeScript, and Go. Use for work on .py, .rs, .ts, or .go files.

repo: code-yeongyu/oh-my-openagent

热度

GitHub 星标
70k
排名
#3136
许可证
NOASSERTION
更新时间
2026/10/15

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能