一键导入
coding-standards
duklog coding standards, testing requirements, and review checklist. Use when reviewing code, writing tests, or checking quality.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
duklog coding standards, testing requirements, and review checklist. Use when reviewing code, writing tests, or checking quality.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | coding-standards |
| description | duklog coding standards, testing requirements, and review checklist. Use when reviewing code, writing tests, or checking quality. |
return, match over if let.unwrap()/.expect() in lib code (only tests and main.rs)thiserror error type; propagate with ?::new() or a dedicated constructor that enforces validation. Struct literal construction in the storage layer silently bypasses invariants (e.g., tx_count >= 1) that ::new() enforces.ok_or_else guards that catch None but silently accept invalid Some(0) or empty-string values.pub fn tested with success and failure pathsis_ok()/is_empty() — critical for mutation testingfn foo_is_idempotent(s: String) -> boolif !s.is_ascii() { return true; } guard in quickcheck properties for ASCII-domain functions (callsigns, grid squares) to avoid Unicode expansion false failurestempfile::tempdir() for storage tests — never real pathstx_count: 0, empty section) — not just missing fieldsmain.rs setup, event loop methods requiring a real terminaldraw_* functions with TestBackend render tests (not excluded from coverage)#[mutants::skip] on draw functions (mutation testing visual layout isn't productive)src/model/, src/adif/, src/storage/, handle_key() methodsExtract a dedicated widget (a new concrete struct implementing a trait) when either of these is true:
set_default called twice) is the code smell.FormField grew a clear_on_first_input flag that only applies to RST fields, that behavior belongs in a dedicated RstField type, even if there were only one RST field.The general principle: extract a widget to encapsulate its own logic and behavior, not only when you have duplicates. A widget owns its invariants (defaults, reset semantics, mode-aware updates) and enforces them internally — callers should not need to know how it works.
A well-extracted widget:
RstField::new(label, default)) rather than applied post-constructionreset() semantics appropriate to the input type (RST restores to default; text clears to empty)draw_* functions should read like prose — delegate formatting and row-building to small private helpers; the top-level function orchestrates, it does not inline per-cell logicmatch arm inside a draw_* function contains more than ~3 lines of data transformation (e.g., .iter().take(n).map(|qso| Row::new(vec![...])) with 5+ fields), extract a private helper:
fn format_rst(qso: &Qso) -> String for repeated format!("{}/{}", qso.rst_sent, qso.rst_rcvd)fn format_timestamp(qso: &Qso) -> String for repeated .format("%H:%M").to_string()fn qso_to_row_general(qso: &Qso) -> Row / fn qso_to_row_pota(qso: &Qso) -> Row per type — or a trait if the dispatch pattern warrants itToRecentRow / similar trait with per-variant impls when the same "build a Row from a Qso" logic branches on QsoFormType across more than one functionBefore finishing any change, scan the files you modified for:
if let chains that should be match, explicit return that should be a tail expression, in the code you touchedIf you find something outside the direct scope of the task, fix it in the same PR as a clearly labeled "cleanup" commit. Do not defer cleanup to a future PR that may never come.
<FIELDNAME:length>value (length = byte length)STATION_CALLSIGN, CALL, QSO_DATE (YYYYMMDD), TIME_ON (HHMMSS), BAND, MODE[A-Z]{1,3}-\d{4,5}///) on all pub itemsadif_str()/from_adif_str() methods, add a doc comment citing the spec source (e.g., the relevant file in docs/reference/) and explain the field name used in storage (e.g., "APP_DUKLOG_POWER")docs/ when implementing or changing features:
docs/user-guide.md — screen descriptions, keybindings, workflowsdocs/architecture.md — module layout, Action enum, design decisionsdocs/roadmap.md — move completed phases, update remaining workdocs/adif-format.md — if ADIF fields or format changesCreate a pull request after code review
Process PR feedback, user corrections, code review findings, or self-observed patterns and update project memory, rules, and standards accordingly. Use proactively after receiving PR review comments, user corrections, or when patterns emerge from code review or self-reflection.
Post-implementation retrospective. Run after completing any non-trivial task to extract patterns, surprises, and lessons and persist them to rules and memory without waiting for user feedback. Use proactively after creating a PR or finishing a significant feature.
Commit changes after running CI checks
Search Rust crate documentation for a type, trait, function, or method. Usage: /search-rust-doc {crate} {query}