用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/canonical/pragma --skill add-standard命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
基于 SOC 职业分类
正在显示 SKILL.md
| name | add-standard |
| description | Create and add a new code standard to the code-standards package |
Create and add a new code standard to the code-standards package.
Use this skill when:
Before creating a new standard, always check if one already exists:
PREFIX cs: <http://pragma.canonical.com/codestandards#>
SELECT ?standard ?description WHERE {
?standard a cs:CodeStandard ;
cs:description ?description .
FILTER(CONTAINS(LCASE(STR(?standard)), "your-topic"))
}
Or use lookup:
sem_lookup(type: "cs:CodeStandard", filters: {"@id": {"$contains": "your-topic"}})
List existing categories to find the right fit:
PREFIX cs: <http://pragma.canonical.com/codestandards#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT ?category ?label ?slug WHERE {
?category a cs:Category ;
rdfs:label ?label ;
cs:slug ?slug .
}
Available Categories:
| Category | Slug | Description |
|---|---|---|
| React | react | React component development |
| CSS | css | CSS technical implementation |
| Styling | styling | Design system styling patterns |
| Code | code | General TypeScript standards |
| Storybook | storybook | Storybook documentation |
| Icons | icons | Icon implementation |
| Packaging | packaging | Package structure and exports |
| Rust | rust | Idiomatic Rust development |
| Git | git | Git workflow conventions |
| TSDoc | tsdoc | Documentation conventions |
| Turtle | turtle | RDF/Turtle authoring |
| UI Blocks | ui-blocks | Framework-agnostic capabilities and patterns for UI blocks |
If no existing category fits, create a new one (see Section 5).
Standard identifiers follow a hierarchical compact IRI pattern: cs:{category}.{domain}.{topic}
Pattern: ^cs:[a-z]+(\.[a-z0-9_]+){2,}$
Examples:
cs:react.component.structure.foldercs:css.selectors.namespacecs:styling.tokens.creationcs:react.hooks.namingGuidelines:
cs:cs:name only for an optional human-readable display titleCreate a new standard instance in the appropriate data file under data/.
Template:
cs:category.domain.topic a cs:CodeStandard ;
cs:name "Human Readable Title" ;
cs:hasCategory cs:category ;
cs:description "Clear, concise description of what this standard covers and why it matters." ;
cs:do [
cs:description "First recommended practice." ;
cs:language "typescript" ;
cs:code """
// Example showing the correct approach
const good = true;
"""
] ;
cs:do [
cs:description "Second recommended practice." ;
cs:language "typescript" ;
cs:code """
// Another correct example
const alsoGood = true;
"""
] ;
cs:dont [
cs:description "First anti-pattern to avoid." ;
cs:language "typescript" ;
cs:code """
// Example showing what NOT to do
const bad = true;
"""
] ;
cs:dont [
cs:description "Second anti-pattern." ;
cs:language "typescript" ;
cs:code """
// Another bad example
const alsoBad = true;
"""
] .
Each cs:do and cs:dont is a blank node (cs:Example) with structured fields:
cs:description — What the example demonstrates (required)cs:language — Language of the code block, e.g. "typescript", "rust", "css", "bash", "svg" (optional, omit when no code)cs:code — The code content (optional, omit for description-only examples)Required Properties:
cs:hasCategory - Reference to a Category instancecs:description - What and why (plain text or markdown)cs:do - One or more positive examples (blank nodes)cs:dont - One or more negative examples (blank nodes)Optional Properties:
cs:name - Human-readable display titlecs:extends - Reference to a parent standard this builds uponIf your standard doesn't fit existing categories:
cs:new_category a cs:Category ;
rdfs:label "Category Name"@en ;
rdfs:comment "Description of what this category covers"@en ;
cs:slug "slug-name" .
When your standard builds on another:
cs:react.component.props.special_case a cs:CodeStandard ;
cs:name "React Props Special Case" ;
cs:extends cs:react.component.props ;
cs:hasCategory cs:react ;
cs:description "Specific guidance that builds on the general props standard." ;
cs:do [
cs:description "Example of the specific pattern." ;
cs:language "typescript" ;
cs:code """
// ...
"""
] ;
cs:dont [
cs:description "Anti-pattern to avoid." ;
cs:language "typescript" ;
cs:code """
// ...
"""
] .
Query to find potential parent standards:
PREFIX cs: <http://pragma.canonical.com/codestandards#>
SELECT ?standard WHERE {
?standard a cs:CodeStandard .
FILTER(STRSTARTS(STR(?standard), STR(cs:react.component.props)))
}
After writing the standard, validate the Turtle syntax:
sem check code-standards
Then verify the standard loads correctly:
sem_lookup(type: "cs:CodeStandard", filters: {"@id": "cs:category.domain.topic"})
The @id must always use the canonical compact IRI. Do not look up standards by cs:name.
Standards are organized by category in data/:
code-standards/
├── definitions/
│ └── CodeStandard.ttl # Ontology schema
├── data/
│ ├── react.ttl # React standards
│ ├── css.ttl # CSS standards
│ ├── styling.ttl # Styling standards
│ ├── code.ttl # General code standards
│ ├── storybook.ttl # Storybook standards
│ └── icons.ttl # Icon standards
└── skills/
└── standards-guide/
└── SKILL.md
Add new standards to the file matching their category.
cs:do blank node is one discrete positive examplecs:description explains what the example demonstratescs:language must match the code block language (e.g. "typescript", "css", "rust")cs:code contains the actual code — no markdown fences neededcs:dont blank node is one discrete negative examplecs:description should explain WHY it's problematicfoo/barAdding a new standard for React error boundaries:
# In data/react.ttl
cs:react.component.error_boundaries a cs:CodeStandard ;
cs:name "React Error Boundaries" ;
cs:hasCategory cs:react ;
cs:description "Error boundaries must be used to catch JavaScript errors in component trees and display fallback UI. They should be placed strategically to isolate failures without breaking the entire application." ;
cs:do [
cs:description "Wrap feature sections with error boundaries to isolate failures." ;
cs:language "tsx" ;
cs:code """
const Dashboard = () => (
<div className="ds dashboard">
<ErrorBoundary fallback={<WidgetError />}>
<AnalyticsWidget />
</ErrorBoundary>
<ErrorBoundary fallback={<WidgetError />}>
<ActivityWidget />
</ErrorBoundary>
</div>
);
"""
] ;
cs:do [
cs:description "Provide meaningful fallback UI that helps users understand and recover." ;
cs:language "tsx" ;
cs:code """
const WidgetError = () => (
<div className="ds widget-error">
<p>This section couldn't load.</p>
<button onClick={() => window.location.reload()}>
Refresh page
</button>
</div>
);
"""
] ;
cs:dont [
cs:description "Wrap the entire application in a single error boundary." ;
cs:language "tsx" ;
cs:code """
// Bad: One error anywhere crashes everything
const App = () => (
<ErrorBoundary>
<Header />
<Main />
<Footer />
</ErrorBoundary>
);
"""
] ;
cs:dont [
cs:description "Use generic or unhelpful fallback messages." ;
cs:language "tsx" ;
cs:code """
// Bad: Doesn't help the user
const fallback = <div>Something went wrong</div>;
"""
] .
cs:extends when your standard builds on another