seniorengineercoding
安装方式
先用 Prompt 核对来源与依赖。也可下载安装包。
用 AI 助手安装
复制提示词,让助手先核对固定版本和依赖。
查看 Prompt收起 Prompt
先检查当前 Agent 是否已安装 SkillPI Skill Finder。如果尚未安装,请按官方仓库的说明安装并启用:https://github.com/Findskills/skillpi。然后使用 Skill Finder 打开此 SkillPI 详情页并定位 "seniorengineercoding":https://skillpi.com/zh/skills/deepskill-8263690704fd14d8fbd726c373fb31b6bdb237e9281166a0dbd9770979656995。安装前核对上游来源和版本:https://github.com/EliasOulkadi/shokunin。来源不一致时停止并说明差异。核对通过后,用 Skill Finder 安装目标 Skill,并报告安装路径和来源版本。
来源与配置
github.com
配置方式待核实
请查看原始来源中的适用工具、依赖和权限要求。
安装实测待补充
在编写、编辑或重构任何代码时,遵循高级软件工程师的标准。适用于编写函数、构建功能、修复缺陷、设计模块或改进现有代码等所有编码任务——即便用户未明确提出质量要求。目标是产出生产级代码:可读性强、正确、易维护、安全可靠,并具备故障感知能力。本技能在任何规模的编码工作中始终生效。
介绍来源: third_party · EliasOulkadi · 1.0.0 参考来源
SkillPi 解读
- 能完成的任务
- 翻译待完成,请参阅来源文档。
- 适合谁
- 来源文档未说明。
- 输入和输出
- 来源文档未说明。
- 软件、账号及付费要求
- 来源文档未说明。
- 限制与区别
- 来源文档未说明。
- 实测状态
- 未测试
文件浏览
Frontmatter
name: Senior Engineer Coding
description: >
Apply senior software engineering standards when writing, editing, or refactoring
any code. Use this skill whenever the user asks to write a function, build a feature,
fix a bug, design a module, or improve existing code — even if they don't mention
quality explicitly. The goal is production-grade code: readable, correct, maintainable,
secure, and failure-aware. Always active for any coding task, at any scale.
triggers:
- "senior engineer"
- "production code"
- "production-grade"
- "write quality code"
- "robust code"
- "maintainable code"
- "secure code"
- "production quality"
negatives:
- "design"
- "architecture"
- "testing"
- "performance optimization"
- "animation"
license: MIT
compatibility: opencode
metadata:
version: "1.0.0"
workflow: general
audience: developersSenior Engineer Coding
Mindset
Write code for the next engineer who has to change it at 2am with no context. Clean code is risk management. Every production incident traces back to unclear, poorly structured, or hard-to-change code — not missing cleverness.
The standard: a teammate can safely change the code without fear, and explain what it does after a quick read.
1. Naming — Highest ROI Habit
Good names eliminate comments, prevent misunderstandings, and make refactoring safe.
Rules:
- Name by intent, not by type or storage:
emailAddressnotemailString - Use domain language: reflect business concepts (
Invoice,Subscription,Refund) - Include units in names:
timeoutMs,priceCents,fileSizeBytes - Make booleans read as questions:
isEnabled,hasAccess,shouldRetry - Name from the caller's perspective:
order.chargePayment()notorder.process() - Be consistent: one concept, one word. Never
userin one place andcustomerin another for the same entity
Avoid:
- Noise words:
manager,helper,data,info,handler(unless genuinely descriptive) - Abbreviations that don't scale:
usrAcctMgr,calcDisc - Overly generic verbs:
process(),handle(),doWork(),run() - Single-letter variables outside tiny loops:
d,x,tmpcause real production bugs
2. Functions — Small, Focused, Predictable
One function = one job. If you can't describe it in one sentence, it does too much.
Guard clauses over nested ifs:
// Wrong — pyramid of doom, hides assumptions
if (user != null) {
if (user.isActive()) {
if (hasAccess(user)) {
process(user)
}
}
}
// Right — early returns, happy path stays flat
if (user == null) return
if (!user.isActive()) return
if (!hasAccess(user)) return
process(user)
Limit parameters:
- More than 3 parameters → create a request/options object
- Long param lists break silently when order is swapped; objects don't
Separate computation from I/O:
- Pure logic (calculation, transformation) → separate from functions that read files, call APIs, write DBs
- Pure functions are easier to test, easier to reason about, and have no hidden side effects
Command/Query separation:
- Functions that return data → must not mutate state
- Functions that mutate → return a status/result, not data
3. No Magic Numbers or Strings
Every hardcoded value with business meaning is a future bug.
// Wrong
price * 1.21
if (status === 3)
setTimeout(fn, 86400000)
// Right
const VAT_RATE = 0.21
const STATUS_SHIPPED = 3
const ONE_DAY_MS = 24 * 60 * 60 * 1000
If a value can change, or has meaning beyond its face value, it must be a named constant.
4. Error Handling — Fail Fast, Fail Clearly
Validate inputs at the boundary:
- Check early, fail fast, with an actionable message
- Never let bad data travel deep into the system before exploding
Make failures explicit:
// Wrong — vague, no context
throw new Error("Something went wrong")
catch (e) { console.log(e) }
// Right — who failed, what failed, what identifier
throw new Error(`Payment failed for orderId=${order.id}: ${e.message}`)
logger.error({ orderId: order.id, userId: user.id, error: e.message })
Design for failure, not success:
- APIs fail. Network is unreliable. Data can be malformed. Assume all of it.
- Every external call needs: timeout, error handling, and at minimum a logged failure
Don't swallow exceptions:
- Empty
catch {}blocks are production bugs waiting to happen - If you catch, you must log (with context) or rethrow
5. DRY — Don't Repeat Yourself
Duplication is a defect multiplier. One version rounds. Another doesn't. Both are "correct".
- Extract shared logic the moment you write it a second time
- Centralize business rules: discount logic, tax calculation, validation rules
- One source of truth per concept
But don't over-DRY:
- Two functions that look similar but represent different concepts → keep them separate
- Premature abstraction is worse than mild duplication
6. KISS — Simplest Solution That Works
// Wrong — "clever" but unmaintainable
Optional<Optional<List<Data>>> result = ...
// Right — obvious and safe
return include ? List.of(data) : List.of()
Rules:
- Choose the simplest approach that solves the problem
- If you're proud of how clever it is, it's probably too clever
- Future you with no sleep at 2am must understand it immediately
7. Structure — Separation of Concerns
Boundary test: if changing one feature requires edits in many unrelated places, the boundaries are wrong.
Keep these separated:
- UI vs business logic — never mix rendering with rules
- Domain vs infrastructure — business logic must not depend on DB/HTTP/filesystem directly
- Feature modules — group by feature, not by layer when it reduces cross-module coupling
Composition over inheritance:
// Wrong — tight coupling through inheritance
class EmailNotifier extends Order {}
// Right — explicit dependency
class OrderService {
constructor(private notifier: Notifier) {}
}
Inheritance spreads behavior implicitly. Composition makes dependencies explicit and swappable.
8. Comments — Why, Never What
The code explains what. Comments explain why.
Good comments:
// Retry once to handle transient network blips — removing this caused incident #4821
retryOnce(request)
// Using soft deletes — this query MUST include deleted_at IS NULL
// or deactivated accounts appear in results
Bad comments (delete these):
// Loop through users
for (const user of users) { ... }
// Set name
this.name = name
Best outcome: refactor the code until the comment is unnecessary.
If a TODO exists, it must have an owner and a date. Ownerless TODOs become permanent.
9. Security — Non-Negotiable Defaults
Apply these on every piece of code, without being asked:
- Never trust external input — validate and sanitize everything from users, APIs, files
- Parameterize queries — never concatenate user input into SQL
- No secrets in code — no API keys, passwords, or tokens hardcoded anywhere
- Auth checks at every endpoint — don't assume a caller is authenticated
- Principle of least privilege — request only the permissions the code actually needs
- Error messages must not leak internals — stack traces, DB queries, and file paths stay in logs, never in user-facing responses
10. SOLID — Applied With Concrete Patterns
Apply when it reduces coupling or improves testability. Don't add layers that don't solve a real problem. Each principle below includes the specific code smell it prevents.
S — Single Responsibility
One reason to change per module. If it changes for two different reasons, split it.
Smell: A class/service mixes persistence, business logic, and notification:
// Bad — 3 reasons to change
class OrderService {
save(order) { /* write to DB */ }
calculateTax(order) { /* math */ }
sendConfirmation(order) { /* email */ }
}
Fix:
class OrderRepository { save(order) }
class TaxCalculator { calculate(order) }
class OrderNotifier { sendConfirmation(order) }
class OrderService {
constructor(private repo: OrderRepository, private tax: TaxCalculator, private notifier: OrderNotifier) {}
async process(order) { await this.repo.save(order); await this.notifier.sendConfirmation(order); }
}
O — Open/Closed
Extend behavior by adding code, not rewriting existing code.
Smell: A function with a growing switch/if-else for each new type:
// Bad — adding a new payment method means editing this function
function processPayment(type, amount) {
if (type === 'credit') { /* ... */ }
else if (type === 'paypal') { /* ... */ }
// add else-if for every new type
}
Fix:
interface PaymentProcessor { process(amount: number): void }
class CreditProcessor implements PaymentProcessor { process(amount) { /* ... */ } }
class PaypalProcessor implements PaymentProcessor { process(amount) { /* ... */ } }
// Add new processors without touching existing code
L — Liskov Substitution
Subtypes must be substitutable for their base types. A caller using the parent type must work correctly with any child.
Smell: A subclass throws exceptions the parent doesn't, or returns different types:
class FileStorage { save(file: Buffer): void }
class S3Storage extends FileStorage {
save(file: Buffer): void { throw new Error("S3 timeout") } // Breaks callers expecting silent success
}
Fix: Design by contract. Document preconditions/postconditions. Don't narrow the output or widen the input.
I — Interface Segregation
Small, focused interfaces over god-objects with 20 methods.
Smell: A class is forced to implement methods it doesn't need:
interface Worker { eat(): void; work(): void; sleep(): void }
class Robot implements Worker {
eat() { throw "I don't eat" } // Forced to implement
work() { /* ... */ }
sleep() { throw "I don't sleep" }
}
Fix:
interface Workable { work(): void }
interface Eatable { eat(): void }
interface Sleepable { sleep(): void }
class Robot implements Workable { work() { /* ... */ } }
class Human implements Workable, Eatable, Sleepable { work() { /* ... */ }; eat() { /* ... */ }; sleep() { /* ... */ } }
D — Dependency Inversion
Depend on abstractions, not concretions. High-level modules should not depend on low-level modules.
Smell: Business logic directly instantiates infrastructure:
class ReportGenerator {
private db = new MySQLDatabase() // Tight coupling to MySQL
}
Fix:
interface Database { query(sql: string): Result }
class ReportGenerator {
constructor(private db: Database) {} // Swappable: MySQL, Postgres, mock
}
Reality check: if SOLID adds layers without reducing risk or improving clarity → don't apply it.
11. Code to Be Reviewed
Every change will be read by another engineer. Write with that in mind.
- Keep diffs small and focused — one PR per concern
- Meaningful commit messages:
Add null check to prevent crash when user profile is missingnotfix bug - No reformatting mixed with logic changes — they belong in separate commits
- Self-review before submitting — read your own diff as if you're reviewing someone else's work
Gotchas — Mistakes That Cause Real Production Bugs
These are concrete errors to avoid, learned from real incidents:
- Updating a value in 6 places instead of 1: always ask "where is this defined?" before editing a value
- Assuming a variable name's meaning:
dmeantdaysin one context anddiscountin another — causing a retry miscalculation - Removing "useless" code without understanding why it exists: a retry that looked dead was handling transient network failures — removing it caused incidents
- Mutating state inside a query function: violates Command/Query separation, causes unpredictable behavior
- Writing the happy path only: always ask "what happens if this returns null/undefined/error?"
- Long functions that batch unrelated operations: when email sending fails, the whole function retries, duplicating data — keep operations separate
- Missing
deleted_at IS NULLon soft-delete tables: a query that returns deactivated users looks correct until a customer calls - Mocking too much in tests: tests that mock internals break on every refactor while missing real bugs — test behavior, not implementation
Quick Self-Check Before Finishing
Before marking any code task done, run through:
- [ ] Names reveal intent without needing comments?
- [ ] Every function does one thing?
- [ ] No magic numbers or strings?
- [ ] Edge cases handled (null, empty, error)?
- [ ] No secrets or sensitive data hardcoded?
- [ ] No duplicated logic?
- [ ] Lint and typecheck pass?
- [ ] The next engineer can change this safely?
Workflow
- Understand intent — read the task requirements. Identify the boundary of the change and what must not be touched.
- Survey surroundings — grep/glob for callers, importers, and dependent code. Understand how the changed code fits into the larger system.
- Plan the change — identify the minimal set of files and lines that must change. Prefer surgical edits over rewrites.
- Write clear, fail-safe code — guard clauses over nested ifs. Named constants over magic values. Parameterized queries over string interpolation. Explicit error handling at every boundary.
- Self-review the diff — read your own changes as if reviewing a teammate's PR. Check naming, edge cases, security, and style consistency.
- Verify correctness — run lint, typecheck, and the narrowest test that exercises the change. Fix any failures before claiming completion.
Error Handling
| Cause | Fix |
|---|---|
| Null/undefined cascading through functions | Validate at boundary. Return early with explicit null guards. Never propagate null silently. |
| Nested conditionals creating unreachable branches | Flatten with guard clauses. Return/fail early on invalid states. |
| Long functions mixing I/O with business logic | Separate pure computation from I/O. Extract I/O to dedicated functions. |
| Swallowed exceptions in empty catch blocks | Always log with context and rethrow, or handle explicitly. Never empty catch {}. |
| API/timeout failures with no recovery | Add retry with jitter, timeout, and circuit breaker for every external call. |
| Race conditions from shared mutable state | Use transactions for multi-step writes. Add locking or atomic operations for shared state. |
| Missing auth checks on endpoints | Verify auth middleware is applied to every endpoint. Check authorization for the specific resource, not just login status. |
| Magic numbers scattered across codebase | Extract to named constants with descriptive names and units. |
Anti-Patterns
| Pattern | Problem | Fix |
|---|---|---|
| "Manager"/"Helper"/"Handler" classes | Vague naming hides responsibility | Name by intent and domain concept: OrderRepository, TaxCalculator |
| Functions with 5+ parameters | Argument order bugs, hard to call | Create a request/options object. Limit to 3 max. |
| Comments explaining what the code does | Code should be self-documenting | Refactor until the comment is unnecessary. Keep only "why" comments. |
| Premature abstractions ("just in case") | Adds complexity for imaginary future needs | Abstract only when duplication exists. YAGNI. |
| Mixing concerns in one class/service | One class changes for 3 different reasons | Apply Single Responsibility: persistence, business logic, and notification belong in separate classes. |
| Inheritance chains over 2 levels deep | Implicit behavior, hard to trace | Prefer composition. Inject dependencies explicitly. |
| Processing user input without validation | Injection, corruption, crashes | Validate and sanitize at the system boundary before any processing. |
| Throwing generic Error with no context | Debugging requires grep, not error messages | Include what failed, what identifier, and actionable context in every error. |
Checklist
- [ ] Function does one thing — if it needs a comment to explain sub-steps, extract them
- [ ] Error handling covers all failure modes (null, network, auth, rate limit)
- [ ] Names are precise and reveal intent (no abbreviations, no generic terms)
- [ ] Tests exist for the critical path (not 100% coverage, but core logic is covered)
- [ ] Security review done for any auth, input, or data exposure surface
Sources
- Robert C. Martin — "Clean Code" (Prentice Hall)
- Martin Fowler — "Refactoring" (Addison-Wesley, 2nd Edition)
- John Ousterhout — "A Philosophy of Software Design" (Yaknyam Press)
- Michael Feathers — "Working Effectively with Legacy Code" (Prentice Hall)
- Steve McConnell — "Code Complete" (Microsoft Press, 2nd Edition)
- Hunt & Thomas — "The Pragmatic Programmer" (Addison-Wesley, 20th Anniversary)
- Kent Beck — "Implementation Patterns" (Addison-Wesley)
- OWASP Top 10 — owasp.org/www-project-top-ten
安全与评测信息
质量评测
满分100 · 来自 SkillPi LAB 实验室的评测报告。
亮点
- 提供全面的高级软件工程师编码标准,涵盖命名、函数设计、错误处理、安全、SOLID 原则等核心实践
- 适用于广泛的开发场景,显著提升代码质量、可读性与可维护性,具有高度实用价值
待提升项
-
触发词覆盖不全 原报告严重程度:轻微
触发词未覆盖如 'refactor', 'code review', 'clean code' 等常见相关编码场景
改进建议:建议补充更多与代码质量、重构、审查相关的触发词以提升触发覆盖率
亮点
- 现有触发词如 'senior engineer', 'production code', 'robust code' 边界清晰,能有效识别目标场景
待提升项
-
缺少 When to Use 章节 原报告严重程度:轻微
文档结构完整但未明确设置 'When to Use' 使用场景说明章节
改进建议:建议增加 'When to Use' 章节,明确说明该 Skill 适用的具体编码任务类型
亮点
- 结构清晰,分章节详述各项编码原则,包含大量代码示例与反模式说明
- frontmatter 完整,文档长度适中,易于阅读和理解
亮点
- 内容为编码规范与最佳实践,不涉及外部工具调用,逻辑自洽,无执行失败风险
- 涵盖错误处理、安全、边界检查等关键可靠性要素,指导性强
取前四项原始分值的算术平均,四舍五入取整。可通过收录报告核对各项评分与说明,运行记录需单独查证。
正文静态检测
100 / 100 · skillpi-20261123-no-r3-v1
正文未命中当前规则。
分数仅反映正文中的规则命中,供使用前参考。附件与运行行为不在此评分范围内。
权限与使用前检查
根据当前主文档自动整理,命中内容可能是示例或防护说明;不是实际权限声明,也未覆盖附件、外部依赖或运行行为。
-
保存或修改文件
先确认输出目录和同名文件是否会被覆盖;重要文件保留备份,优先写入新的输出目录。
主文档提及 · 第 268 行
安全评级与访问范围
safe · 静态证据核验,不代表运行安全保证。
来源文档未说明。
使用前请由宿主核对并授权实际文件读写、外部服务和联网目的地;本站的核验不会授予任何运行权限。
用户讨论
还没有已核实的点评。