core-principles
Go development principles including SRP, dependency injection, framework-less web, CSS-first interactivity, and file structure constraints. Use for any Go project setup or code review.
适合你,如果你用 Go 写项目并希望遵循最佳实践
/ 通过 npx 安装 校验哈希
npx oh-my-skill add tinywasm/devflow/core-principles/ 通过 bash 安装
curl -fsSL https://oh-my-skill.com/install.sh | bash -s -- tinywasm/devflow/core-principles/ 已经装过?验证本机副本,不用重装
npx oh-my-skill verify tinywasm/devflow/core-principles安装目标可用 --agent / --scope 或 --to 明确指定;省略时只会在唯一已存在的 agent 目录上自动选择,零命中或多命中会停止并提示。content_hash 缺失或不一致均拒装。
1GitHub stars
~874上下文体积 · 单文件
索引托管
怎么用
商店整理自技能原文 · 版本 6481063 · 表述以原文为准它做什么
Claude 会遵循单一职责原则、强制依赖注入、无框架开发、CSS优先交互、严格文件结构等原则来编写或审查Go项目代码。
什么时候触发
当用户要求设置Go项目结构、进行代码审查,或询问Go开发最佳实践时触发。
装好后可以这样说
Claude会检查文件职责是否单一。
Claude会生成符合DI原则的入口文件。
技能原文 SKILL.md
Core Principles
- Single Responsibility Principle (SRP): Every file (CSS, Go, JS) must have a single, well-defined purpose. This must be reflected in both the file's content and its naming convention.
- Mandatory Dependency Injection (DI):
- No Global State: Avoid direct system calls (OS, Network) in logic.
- Interfaces: Define interfaces for external dependencies (
Downloader,ProcessManager). - Composition: Main structs must hold these interfaces.
- Injection:
cmd/<app_name>/main.gois the ONLY place where "Real" implementations are injected. - Thin Main / Fat Library:
cmd/*/main.gofiles MUST be minimal — only argument parsing and dependency injection. ALL business logic MUST live in exported, testable library functions. Never put orchestration logic, conditionals, or error handling beyond basic print/exit in main.
- AI-Consumable CLIs (Execution Contract): Any
cmd/*binary that may be driven by an automation or LLM (not only humans) MUST honor a deterministic execution contract so a caller can branch on results without a human: - Non-interactive by default: running with no arguments prints help and exits — it never blocks on a TUI or
stdin. Interactive/TUI modes are opt-in behind an explicit flag (e.g.-tui). Long-lived daemons (-mcp) are non-interactive too: agents talk to them over their protocol, not stdin. - Stream separation — stdout = data, stderr = diagnostics:
stdoutcarries only consumable output (help, a resolved value, a machine result);stderrcarries all logs, progress and diagnostics. A caller capturing stdout must get clean output — usefmt.Fprintln(os.Stderr, …)for anything diagnostic. - Exit codes as contract:
0on success (including help printed and clean shutdown); non-zero on bad/conflicting flags or startup failure. The agent branches on the code, not on prose. Library functions return errors; the thinmainmaps them to exit codes (that mapping is the only logic allowed inmain). - Structured results belong to the tool surface: when an agent needs rich results, expose them through the program's protocol layer (e.g. MCP/JSON-RPC tools), not by parsing free-form stdout.
- Views belong to the consumer (libraries render no pages): A reusable library exposes flows, data and contracts — routes (
POST /login), models (model.Definition), callbacks, tokens. HOW anything looks (HTML pages, branding, layout composition) is created by the consuming app in its composition root (e.g.config/), typically withtinywasm/formover the library's generated models plus the app's own CSS. A library that renders its own HTML page is a design smell: split the flow (stays in the library) from the view (moves to the consumer). Published layout skeletons (tinywasm/layout) are the one exception — layout structure IS their single responsibility, and even they define only WHERE things go, never WHAT they contain.
- Framework-less Development: For Web projects, use only the Standard Library (HTML/CSS/JS). No external frameworks or libraries are allowed.
- CSS-First Interactivity: Minimize JavaScript usage. All UI interactivity (toggles, menus, states) must be implemented using pure CSS whenever possible.
- Minimalist JS: Use JavaScript only as a last resort for logic that cannot be handled by CSS or the Go backend.
- Strict File Structure:
- Flat Hierarchy: Go libraries must avoid subdirectories. Keep files in the root.
- Max 500 lines: Files exceeding 500 lines MUST be subdivided and renamed by domain.
- Test Organization: If >5 test files exist in the root, move ALL tests to a
tests/directory.
按 MIT 许可原样转载,未经改动 · 在 GitHub 查看 →
评论
登录即可评论;带「已验证安装」的,是发布者名下有本店的安装或持有记录。
…