본문으로 건너뛰기
cccskills
무료GitHub에 공개

rustdoc

Add or revise source-level Rustdoc for Shift Rust APIs. Use before writing or editing documentation comments in `.rs` files, especially for public or crate-visible APIs, domain structures, compiler adapters, persistence boundaries, trait implementations, unsafe code, or any API where ownership, units, coordinate spaces, mutation, I/O, sparse behavior, failure modes, panics, or concurrency are easy to misunderstand.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

설치 방법 보기

포함된 파일(1)

  • SKILL.md6.2 KB

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

Rustdoc — Source API Contracts

Write Rustdoc as the stable contract a caller or maintainer needs without reconstructing the implementation.

Use /// immediately before an item and //! at the start of a module or crate. Let Rust's types describe shape; document semantics the type system cannot express.

Runbook

  1. Identify the boundary and audience: caller, implementer, compiler adapter, persistence layer, or maintainer.
  2. Read the surrounding module, relevant callers, and behavior tests before describing the contract.
  3. Start with one short sentence stating what the item represents or does.
  4. Add only applicable details: ownership, snapshotting, mutation, I/O, units, coordinate domain, fallback, ordering, concurrency, performance, or invariants.
  5. Add conventional sections when required:
    • # Errors for observable failure conditions.
    • # Panics for conditions that actually panic.
    • # Safety for every unsafe API, stating the caller's obligations.
    • # Examples only when call order, conversion, or output is non-obvious.
  6. Link related APIs with intra-doc links such as [Font] or [Self::export].
  7. Delete implementation trivia, current-caller anecdotes, migration history, and statements already obvious from the signature.

What To Document

Prioritize contracts that Rust cannot encode directly:

  • Ownership and lifetime semantics — owned snapshot versus live view, aliasing, cloning, and who may mutate a result.
  • Effects and atomicity — filesystem or database I/O, shared-state mutation, transaction boundaries, and partial-failure behavior.
  • Units and coordinate domains — font units, user coordinates, design coordinates, normalized coordinates, and mapping direction.
  • Resolution and sparsity — exact lookup versus fallback, missing layer versus empty layer, and default-source requirements.
  • Ordering and identity — stable ordering, ID preservation, minted identity, and when a value becomes stale.
  • Failures — error conditions, panic preconditions, cancellation, and unsupported input.
  • Concurrency and performance — thread assumptions, blocking work, hot-path suitability, and important complexity.

Document pub(crate) and private items when they form an architectural seam or carry a non-obvious invariant. Do not document obvious constructors or mechanical work wrappers merely because they are visible within the crate.

Style Rules

  • Open with a direct contract sentence; avoid “This function” and “This struct.”
  • Prefer stable domain language over current implementation wiring.
  • Do not restate parameter or field types in prose.
  • Document fields individually only when their units, ownership, valid range, or meaning is not encoded by the field name and type.
  • Use backticks for values and syntax; use intra-doc links for Rust items.
  • Put module-wide invariants in one //! comment instead of repeating them on every item.
  • Keep algorithmic rationale in ordinary // comments near the algorithm, not in the public contract.
  • Do not copy documentation from an implemented trait. Describe Shift-specific adapter semantics on the implementing type or module.
  • Do not use Rustdoc as a TODO list, changelog, ticket, or warning to future maintainers.
  • Do not promise behavior more strongly than tests and implementation support.

Conventional Sections

Use headings exactly as Rust tooling and readers expect:

/// Writes a TTF compiled from an immutable snapshot of the supplied font.
///
/// The destination is replaced atomically after compilation succeeds.
///
/// # Errors
///
/// Returns [`ExportError`] when the source cannot be represented, compilation
/// fails, or the destination cannot be replaced.
pub fn export(/* ... */) -> Result<FontExportResult, ExportError> {
    // ...
}

For panics, document the actual precondition rather than writing a generic disclaimer:

/// Returns the default source.
///
/// # Panics
///
/// Panics when the font has no default source.

Every unsafe item needs a precise caller obligation:

/// Reads a point from the packed geometry buffer.
///
/// # Safety
///
/// `index` must address a fully initialized point in `buffer`.

Examples and Links

Examples are executable contracts, not decoration.

  • Prefer a compiling doctest with assertions.
  • Use hidden # lines for setup when that keeps the lesson focused.
  • Use no_run for filesystem or process examples; avoid ignore unless the example fundamentally cannot compile in docs.
  • Keep one concept per example and omit examples for trivial accessors.
  • Run doc tests after adding an example.

Use links that Rustdoc can resolve:

/// Creates the snapshot consumed by [`FontExporter::export`].
///
/// See [`FontView`] for the borrowed authoring interface.

Validation

After editing Rustdoc:

  1. Run cargo fmt --all -- --check.
  2. Run the affected crate's tests, including doc tests when examples changed.
  3. Run RUSTDOCFLAGS="-D rustdoc::broken_intra_doc_links" cargo doc --workspace --no-deps --document-private-items for new or changed links.
  4. Run Clippy for affected crates when documentation changes accompany Rust code changes.

Do not enable workspace-wide missing_docs as part of an unrelated change. Introduce lint policy separately after auditing the existing baseline.

Checklist

  • The first sentence states a useful contract.
  • The comment adds information not already encoded by the signature.
  • Units, coordinate spaces, ownership, sparse behavior, and effects are explicit where relevant.
  • Every documented failure, panic, and safety obligation matches reality.
  • Intra-doc links resolve and examples compile.
  • No caller name-drops, implementation history, TODOs, or duplicated trait docs.

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

commit

무료

Canonical rules for writing git commits in the Shift codebase. Use whenever the user asks to commit, stage and commit, create a pull request that requires commits, or draft a commit message. Enforces Conventional Commits, release-note quality, concise subjects, and logical commit boundaries.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

shift-editor/shift3662026년 10월 21일 업데이트

dead-code

무료

Find and remove dead code (unused files, exports, class members) using Knip as a candidate generator, then verify each candidate through AST-level analysis and interface tracing before removing anything. Use when the user asks to clean up unused code, find dead code, or reduce the codebase.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

shift-editor/shift3662026년 10월 21일 업데이트

docs

무료

Update or create DOCS.md files for Shift subsystems. Use this skill whenever the user asks to update docs, refresh documentation, create a DOCS.md, write module documentation, or says "update docs for X". Also trigger after completing a large feature when Claude.md says to update docs — check if any DOCS.md in the affected subsystem needs refreshing.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

shift-editor/shift3662026년 10월 21일 업데이트

Adversarially fact-check DOCS.md files against the actual source code, verifying every concrete claim rather than trusting structure checks. Use when the user asks to audit docs, verify documentation accuracy, check whether docs are still true, or on a scheduled documentation review. This is the semantic layer the mechanical checkers cannot cover.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

shift-editor/shift3662026년 10월 21일 업데이트

issue

무료

Canonical rules for finding, creating, and updating Shift GitHub issues. Use whenever the user asks to file, create, open, update, triage, or search for an issue, or when substantial work needs an issue before a pull request. Prevents duplicates and defines acceptance criteria and pull-request closure semantics.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

shift-editor/shift3662026년 10월 21일 업데이트

jsdoc

무료

Add or revise source-level JSDoc for Shift APIs. Use this skill before writing or editing documentation comments for exported classes, methods, constructors, domain data structures, render frames, reactive state, or any API where caller intent, side effects, lifetime, ownership, or nullability are easy to misunderstand.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

shift-editor/shift3662026년 10월 21일 업데이트

shift-editor의 스킬 모두 보기

이 스킬의 문제 신고