一键导入
convention-writing
How to analyze a codebase for recurring patterns and write effective convention specs that standardize them.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
How to analyze a codebase for recurring patterns and write effective convention specs that standardize them.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Behavioral rules that make AI coding agents more reliable — verification, self-correction, and scope discipline.
Debugging guidance and structured report template for thorough bug investigation, evidence gathering, and root cause documentation.
Cold-audit a completed delivery — verify the spec was actually delivered, challenge performative claims, and produce a what-landed report.
Guidelines for generating self-contained HTML mockups that look professional and are easy to iterate on.
Shared implementation guidance for making minimal, correct, maintainable code changes that fit existing systems.
The doctrine for `/roadmap-review` — interactive triage of roadmap-shape drift, walked one item at a time, with paste-ready resolution phrasing for the active sizing lens.
| name | convention-writing |
| description | How to analyze a codebase for recurring patterns and write effective convention specs that standardize them. |
| compatibility | opencode |
| metadata | {"audience":"convention-author","purpose":"convention-authoring"} |
Teach the convention-author agent how to identify patterns worth standardizing, search a codebase for existing instances, and produce convention specs that are concrete, scoped, and actionable.
Load this skill when running the /convention command or when a delivery lead asks for a new convention to be documented. The convention-author should load this before analyzing the codebase or writing a convention spec.
Not every repeated pattern deserves a convention. A pattern is worth standardizing when it meets at least two of these criteria:
Do not write conventions for patterns that are self-evident from the language or framework, enforced by linting rules already in place, or only relevant to a single file.
Before writing a convention, gather evidence. The convention must be grounded in what the codebase actually does, not what you wish it did.
.hero/conventions/ directory for existing conventions that overlap. If one exists, update it rather than creating a duplicate.Convention specs live in .hero/conventions/{slug}/spec.md. Use the convention template from the spec-format skill.
---
type: convention
status: draft
scope: [glob patterns]
tags: [relevant tags]
---
type must be convention.status starts as draft. It moves to active after review confirms the convention reflects actual codebase practice (or a deliberate decision to change practice).scope is an array of glob patterns that identify which files this convention applies to. This is how hero relevant knows to surface the convention when an agent touches matching files.tags categorize the convention for search and filtering.Scope globs determine when hero relevant injects this convention into agent instructions. Get them right — too broad and the convention clutters every context block; too narrow and it misses files where it matters.
Good scope patterns:
src/api/**/*.ts — all API route files**/migrations/*.sql — all SQL migration files*.go — all Go source filessrc/components/**/*.tsx — all React components**/test/** — all test files regardless of languageBad scope patterns:
* — matches everything, appropriate only for truly universal conventions (naming, commit messages)src/** — too broad for most conventions; be specific about which subdirectoriesWhen in doubt, start narrow. You can always widen scope later.
One clear statement of what this convention standardizes. Not a paragraph — a sentence or two. The reader should immediately understand what this is about.
Good: "All API error responses use the ApiError class and return a consistent { error, code, details } shape."
Bad: "This convention is about how we handle errors in our API layer to ensure consistency across the codebase."
State the conditions precisely. Name file types, modules, situations. The agent reading this needs to know: "Does this apply to the code I'm about to write?"
Show the specific implementation pattern. Include code snippets from the actual codebase. Reference real file paths. If there are multiple valid approaches within the convention, show each one and when to use which.
Pull real examples from the codebase. Include file paths. Show enough code to demonstrate the pattern in context, not just the single line that matches. Agents need to see the surrounding structure.
Show real violations from the codebase (or realistic constructed examples if the codebase is clean). Explain why each anti-pattern is problematic — not just "don't do this" but "this causes X problem."
Every convention has edge cases. Name them. If there are no exceptions, say "None identified" rather than leaving the section out — this signals the convention-author actually considered it.
Write one convention per concern. If you find yourself writing a convention that covers both "how to name files" and "how to structure API responses," split them. Each convention should be independently understandable and independently scoped.
Consolidate when two draft conventions have the same scope, the same audience, and would always be read together. In that case, merge them under the broader name.
A convention is ready for active status when: