AgentSkillsCN

project-conventions

dtvmgr Rust CLI 的项目专用约定。强制要求在所有 ? 运算符上附加明确的错误上下文,仅进行追踪式日志记录,严格划分导入模块,采用 Mise 工具链,并应用 6 条自定义的 AST-Grep 规则。当您编写、审查或修改 .rs 文件,运行构建或测试,或创建提交时,均可使用这些规则。这些规则与 Rust 实现相结合,为项目量身定制了专属规范。

SKILL.md
--- frontmatter
name: project-conventions
description: >-
  Project-specific conventions for the dtvmgr Rust CLI. Enforces mandatory
  error context on all ? operators, tracing-only logging, strict import
  grouping, mise-based tooling, and 6 custom ast-grep rules. Use when
  writing, reviewing, or modifying .rs files, running builds/tests, or
  creating commits. Complements rust-implementation with project-specific rules.
license: AGPL-3.0

Project Conventions — dtvmgr

1. Mandatory Error Context

Every ? operator MUST have .context() or .with_context() attached. Bare ? is forbidden. Enforced by ast-grep rule error-context-required.

rust
// Good
let url = Url::parse(s).context("invalid URL")?;
let val = u32::try_from(n).with_context(|| format!("overflow: {n}"))?;

// Bad — bare ?
let url = Url::parse(s)?;

2. Logging: tracing Only

println!, eprintln!, and dbg! are forbidden in production code. Use tracing macros with structured fields.

rust
tracing::info!(page = page, total = total, "fetched programs");
tracing::warn!(?err, "retry after failure");

Exception: build.rs may use println! with // ast-grep-ignore: no-println-debug. Also enforced by clippy lints print_stdout, print_stderr, dbg_macro.

3. Import Grouping

All use statements at file top level, grouped with blank-line separators:

rust
// 1. std
use std::sync::Arc;

// 2. External crates
use anyhow::{Context as _, Result};
use tokio::sync::Mutex;

// 3. crate / super
use crate::libs::syoboi::types::SyoboiProgram;

Wildcards (*) are forbidden except use super::* in test modules. Aliases (as) are permitted for name conflicts and re-exports.

4. Commands: mise Only

Never run cargo directly. All tasks go through mise run:

TaskCommand
Buildmise run build
Testmise run test
TDD watchmise run test:watch
Doc testsmise run test:doc
Formatmise run fmt
Format checkmise run fmt:check
Lint (clippy)mise run clippy
Lint strictmise run clippy:strict
AST rulesmise run ast-grep
Pre-commitmise run pre-commit
Coveragemise run coverage
Denymise run deny
Build with OTelmise run build -- --features otel

5. Workflow

  1. Write tests first (for new features / bug fixes)
  2. Implement the feature
  3. Run mise run test — all tests must pass
  4. Stage only the relevant files
  5. Run mise run pre-commit (runs fmt:check, clippy:strict, ast-grep)
  6. If errors, fix, re-stage, and re-run mise run pre-commit

6. Code Comments

All code comments (doc comments, inline comments) must be in concise English. Japanese is forbidden in source code.

7. Commit Convention

Conventional Commits format: <type>: <description> or <type>(<scope>): <description>

Allowed types: feat, update, fix, style, refactor, docs, perf, test, build, ci, chore, remove, revert

8. No Blocking I/O in Async

In async fn, synchronous blocking calls are forbidden (severity: error). Enforced by ast-grep rule no-blocking-in-async.

ForbiddenUse instead
std::fs::*tokio::fs::*
std::thread::sleeptokio::time::sleep
std::net::*tokio::net::*
std::process::Commandtokio::process::Command

9. Reference Files

TopicFile
ast-grep rules (6 rules)references/ast-grep-rules.md
Testing patternsreferences/testing-patterns.md
Module & project layoutreferences/module-and-project-structure.md