Skip to main content

new-module

Scaffold a new hardware-isolated module with tests and wiring

来源信息

仓库
weaties/helmlog
最近来源活动
2026年4月21日 16:04
检测到的 SKILL.md 语言
英语
星标
2
分支
2

安装方式

默认使用会先检查来源的 Prompt;你也可以切换为直接命令,或下载本地副本。

检查来源文件

决定是否安装前,请先阅读 SKILL.md,以及 SkillsMP 当前展示的配套文件。

正在显示 SKILL.md

SKILL.md
来源说明 · 只读预览
name
new-module
description
Scaffold a new hardware-isolated module with tests and wiring
disable-model-invocation
true
# New Module: `$ARGUMENTS` Follow this checklist to create a new hardware-isolated module. Use TDD (`/tdd`) for each step that involves code. ## Checklist ### 0. Enter a worktree Before any file edits, make sure the session is in a git worktree. Check `git worktree list` — reuse an existing one via `EnterWorktree(path=...)` if it matches this task, otherwise create a new one via `EnterWorktree(name=...)`. Scaffolding touches `tests/`, `src/logger/`, `main.py`, and often `web.py` and `storage.py` — exactly the kind of multi-file change that collides with other agents sharing the repo. See CLAUDE.md for the full rule. ### 1. Write tests first Create `tests/test_$ARGUMENTS.py` with tests for the module's public API. Use the `storage` fixture from `conftest.py` and mock any external I/O. ### 2. Create the module Create `src/logger/$ARGUMENTS.py`: - Single-purpose, under ~200 lines - All external I/O (HTTP, serial, USB, etc.) isolated in this module - Use dataclasses for structured data - Use `loguru` for logging (never `print()`) - Full type annotations on all functions ### 3. Schema migration (if needed) If the module needs database tables: - Bump `_CURRENT_VERSION` in `storage.py` - Add migration SQL to `_MIGRATIONS` dict - Add async storage methods (CRUD) - Test with the in-memory `storage` fixture ### 4. Web routes (if needed) If the module needs API endpoints or admin UI: - Add to `web.py` following existing patterns - Admin pages: require `require_auth("admin")` - Add nav link in `_nav_html()` - Add web route tests in `test_web.py` ### 5. Wire into main.py - Import the module **only in `main.py`** (hardware isolation principle) - Parse config from env vars - Pass to `_web_loop()` / `create_app()` if needed - Add CLI subcommand if applicable ### 6. Sync dependencies If the module requires new packages: - Add with `uv add <package>` (never edit pyproject.toml manually for deps) - Run `uv sync` and verify the import works - Never use `uv pip install` — it bypasses the lockfile and won't persist ### 7. Update config - Add new env vars to `.env.example` with comments - Update `CLAUDE.md` project structure tree ### 8. Run `/pr-checklist`
在 GitHub 查看