@contentrain/skills 0.1.1 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/README.md +65 -60
  2. package/dist/index.cjs +65 -1
  3. package/dist/index.d.cts +50 -2
  4. package/dist/index.d.cts.map +1 -1
  5. package/dist/index.d.mts +50 -2
  6. package/dist/index.d.mts.map +1 -1
  7. package/dist/index.mjs +65 -2
  8. package/dist/index.mjs.map +1 -1
  9. package/frameworks/nuxt.md +26 -1
  10. package/package.json +3 -1
  11. package/skills/contentrain/SKILL.md +149 -0
  12. package/skills/contentrain/references/architecture.md +212 -0
  13. package/skills/contentrain/references/content-formats.md +279 -0
  14. package/skills/contentrain/references/i18n.md +298 -0
  15. package/skills/contentrain/references/mcp-pipelines.md +192 -0
  16. package/skills/contentrain/references/mcp-tools.md +308 -0
  17. package/skills/contentrain/references/model-kinds.md +330 -0
  18. package/skills/contentrain/references/schema-types.md +177 -0
  19. package/skills/contentrain/references/security.md +146 -0
  20. package/skills/contentrain/references/workflow.md +267 -0
  21. package/skills/contentrain-bulk/SKILL.md +99 -0
  22. package/skills/contentrain-content/SKILL.md +162 -0
  23. package/skills/contentrain-diff/SKILL.md +62 -0
  24. package/skills/contentrain-doctor/SKILL.md +62 -0
  25. package/skills/contentrain-generate/SKILL.md +183 -0
  26. package/skills/contentrain-generate/references/generated-client.md +198 -0
  27. package/skills/contentrain-init/SKILL.md +99 -0
  28. package/skills/contentrain-model/SKILL.md +141 -0
  29. package/skills/contentrain-normalize/SKILL.md +185 -0
  30. package/skills/contentrain-normalize/references/extraction.md +164 -0
  31. package/skills/contentrain-normalize/references/reuse.md +146 -0
  32. package/skills/contentrain-normalize/references/what-is-content.md +115 -0
  33. package/skills/contentrain-quality/SKILL.md +180 -0
  34. package/skills/contentrain-quality/references/accessibility.md +160 -0
  35. package/skills/contentrain-quality/references/content-quality.md +299 -0
  36. package/skills/contentrain-quality/references/media.md +170 -0
  37. package/skills/contentrain-quality/references/seo.md +229 -0
  38. package/skills/contentrain-review/SKILL.md +170 -0
  39. package/skills/contentrain-sdk/SKILL.md +145 -0
  40. package/skills/contentrain-sdk/references/bundler-config.md +135 -0
  41. package/skills/contentrain-serve/SKILL.md +96 -0
  42. package/skills/contentrain-translate/SKILL.md +180 -0
  43. package/skills/contentrain-validate-fix/SKILL.md +92 -0
  44. package/workflows/contentrain-content.md +1 -1
  45. package/workflows/contentrain-generate.md +5 -5
@@ -0,0 +1,299 @@
1
+ ---
2
+ name: content-quality
3
+ description: "Detailed content writing rules: structure, tone, content type patterns, lifecycle"
4
+ ---
5
+
6
+ # Content Quality Rules
7
+
8
+ These rules govern how AI agents create and edit content in Contentrain projects.
9
+ Every rule is mandatory. Violations must be fixed before committing.
10
+
11
+ ---
12
+
13
+ ## 1. Writing Structure
14
+
15
+ ### 1.1 Heading Hierarchy
16
+
17
+ - Use exactly ONE H1 per page. The H1 is the page/entry title.
18
+ - Follow sequential order: H1 -> H2 -> H3 -> H4 -> H5 -> H6.
19
+ - NEVER skip levels. An H4 must be preceded by an H3 in the same section.
20
+ - Do not use headings for visual styling. A heading implies a content section.
21
+
22
+ ### 1.2 Titles
23
+
24
+ - Length: 50-60 characters. Measure before committing.
25
+ - Place the primary keyword within the first 30 characters.
26
+ - Use action-oriented phrasing: "Build a REST API" not "REST API Overview".
27
+ - No clickbait: "You Won't Believe..." is forbidden.
28
+ - No ALL CAPS titles. Use sentence case or title case per project convention.
29
+ - Every title must be unique within its collection.
30
+
31
+ ### 1.3 Excerpts and Descriptions
32
+
33
+ - Length: 120-160 characters. Must be a complete sentence.
34
+ - Summarize the VALUE the reader gets, not the process of writing.
35
+ - GOOD: "Learn how to deploy a Node.js app to production in under 5 minutes."
36
+ - BAD: "This article discusses deployment."
37
+ - End with a period. No trailing ellipsis.
38
+ - Must differ from the title -- do not repeat the title verbatim.
39
+
40
+ ### 1.4 Body Content
41
+
42
+ - Prefer active voice. Passive voice is acceptable only when the actor is unknown or irrelevant.
43
+ - Target reading grade 8-10 (Flesch-Kincaid). Avoid unnecessarily complex sentences.
44
+ - Paragraphs: 3-5 sentences each. Break longer paragraphs.
45
+ - Use transition sentences between sections to maintain flow.
46
+ - Front-load key information -- most important point first in each paragraph.
47
+ - One idea per paragraph. Do not combine unrelated points.
48
+
49
+ ### 1.5 Lists
50
+
51
+ - Use parallel grammatical structure across all items.
52
+ - GOOD: "Install dependencies", "Configure the server", "Run the tests"
53
+ - BAD: "Install dependencies", "Server configuration", "You should run tests"
54
+ - Punctuation: if items are complete sentences, end each with a period. If fragments, no terminal punctuation. Be consistent within a single list.
55
+ - Ordered lists for sequential steps. Unordered lists for non-sequential items.
56
+ - Minimum 2 items in any list. A single-item list is not a list.
57
+
58
+ ### 1.6 No Placeholder Text
59
+
60
+ Reject and replace any of the following immediately:
61
+
62
+ - "Lorem ipsum" or any Latin filler text
63
+ - "TODO", "TBD", "FIXME", "XXX" in content fields
64
+ - "[insert here]", "[your text]", "[placeholder]"
65
+ - "Sample text", "Example content", "Test entry"
66
+ - Empty strings in required fields
67
+
68
+ If the agent cannot produce real content, it must leave the entry in `draft` status and flag the field explicitly. Never commit placeholder text.
69
+
70
+ ### 1.7 No Duplicate Content
71
+
72
+ - The same text block must not appear in multiple entries within a collection.
73
+ - Titles must be unique across all entries in the same collection.
74
+ - Descriptions/excerpts must be unique across all entries in the same collection.
75
+ - If content is shared across entries, extract it to a referenced entry and use a `relation` field.
76
+ - Before writing, query existing entries to confirm no duplication.
77
+
78
+ ---
79
+
80
+ ## 2. Tone and Voice
81
+
82
+ ### 2.1 Project Tone Configuration
83
+
84
+ - Read `.contentrain/context.json` -> `conventions.tone` before writing any content.
85
+ - If the field exists, match the specified tone exactly.
86
+ - If `context.json` does not exist or `conventions.tone` is absent, default to **neutral professional** tone.
87
+ - Never override or ignore the configured tone.
88
+
89
+ ### 2.2 Vocabulary Compliance
90
+
91
+ - Read `.contentrain/vocabulary.json` before writing content.
92
+ - Use canonical terms exactly as defined. Never invent synonyms for canonical terms.
93
+ - If vocabulary defines "Sign up", do not write "Register", "Create account", or "Join".
94
+ - Respect `brand_terms`: use exact casing and spacing as defined.
95
+ - If brand defines "GitHub", never write "Github", "github", or "GH".
96
+ - Respect `forbidden_terms`: never use any term on this list.
97
+ - If `vocabulary.json` does not exist, proceed without term constraints but maintain internal consistency -- pick one term and use it everywhere.
98
+
99
+ ### 2.3 Content Type Voice Mapping
100
+
101
+ Match voice to content type:
102
+
103
+ | Content Type | Voice | Characteristics |
104
+ |---|---|---|
105
+ | Marketing / Landing pages | Persuasive | Benefit-focused, confident, action-oriented, second person ("you") |
106
+ | Documentation / Guides | Instructional | Step-by-step, precise, imperative mood ("Run the command"), third person for concepts |
107
+ | Error messages | Empathetic | Solution-oriented, no blame, explain what happened and what to do next |
108
+ | UI labels | Concise | Consistent terminology, sentence case, no articles unless needed for clarity |
109
+ | Blog posts | Conversational-professional | Engaging, informative, first person plural ("we") acceptable |
110
+ | Changelogs | Factual | Past tense, specific, version-referenced, no marketing language |
111
+
112
+ ### 2.4 Consistency Within an Entry
113
+
114
+ - Do not shift tone mid-entry. If the opening is formal, maintain formality throughout.
115
+ - Do not mix second person ("you") and third person ("the user") within the same entry.
116
+ - Maintain consistent use of contractions: either use them throughout or not at all per project tone.
117
+
118
+ ---
119
+
120
+ ## 3. Content Type Patterns
121
+
122
+ ### 3.1 Blog Post (document kind)
123
+
124
+ Required structure:
125
+
126
+ 1. **Hook opening** (1-2 sentences): State the problem, ask a question, or present a surprising fact.
127
+ 2. **Context** (1 paragraph): Why this topic matters now.
128
+ 3. **Scannable body**: Use H2/H3 subheadings every 2-4 paragraphs. Each section is self-contained.
129
+ 4. **Conclusion** (1 paragraph): Summarize key takeaways.
130
+ 5. **Call-to-action**: Direct the reader to a next step (related post, product, signup).
131
+
132
+ Do not start with "In this article, we will discuss..." -- start with value.
133
+
134
+ ### 3.2 Landing Page (singleton kind)
135
+
136
+ Required sections in order:
137
+
138
+ 1. **Hero statement**: One sentence, max 10 words. State the core value proposition.
139
+ 2. **Problem**: 2-3 sentences describing the pain point.
140
+ 3. **Solution**: How the product/service solves it. Benefit-focused, not feature-focused.
141
+ 4. **Features**: 3-6 features, each with a heading and 1-2 sentence description.
142
+ 5. **Social proof**: Testimonials, logos, statistics. Must reference real data.
143
+ 6. **CTA**: Clear, single action. Use action verbs: "Start free trial", "Get started", "Book a demo".
144
+
145
+ ### 3.3 Documentation (document kind)
146
+
147
+ Required structure:
148
+
149
+ 1. **Prerequisites callout**: List what the reader needs before starting (tools, accounts, knowledge).
150
+ 2. **Overview** (1-2 sentences): What the reader will accomplish.
151
+ 3. **Step-by-step instructions**: Numbered steps, one action per step, code blocks where applicable.
152
+ 4. **Expected result**: What the reader should see/have after completing the steps.
153
+ 5. **Troubleshooting**: Common errors and their solutions. Minimum 2 items.
154
+
155
+ Use imperative mood: "Run the command" not "You should run the command".
156
+
157
+ ### 3.4 Error Messages (dictionary kind)
158
+
159
+ Structure each error message with three parts:
160
+
161
+ 1. **What happened**: State the error clearly. "Your session has expired."
162
+ 2. **Why**: Brief explanation. "Sessions expire after 30 minutes of inactivity."
163
+ 3. **How to fix**: Actionable next step. "Sign in again to continue."
164
+
165
+ Rules:
166
+ - No blame language: "Invalid input" not "You entered invalid input".
167
+ - No technical jargon in user-facing errors.
168
+ - No naked error codes: always pair codes with human-readable text.
169
+
170
+ ### 3.5 Form Labels (dictionary kind)
171
+
172
+ - Use noun or noun phrase: "Email address", "Password", "Company name".
173
+ - Sentence case consistently: "Email address" not "Email Address".
174
+ - No colons at the end of labels.
175
+ - Helper text: one sentence explaining what to enter or format requirements.
176
+ - Consistent phrasing across all forms in the project.
177
+
178
+ ### 3.6 Navigation Items (dictionary kind)
179
+
180
+ - 1-2 words maximum.
181
+ - Use verbs for actions: "Sign in", "Download", "Contact".
182
+ - Use nouns for destinations: "Dashboard", "Settings", "Pricing".
183
+ - No abbreviations unless universally understood.
184
+ - Consistent capitalization: match the project convention.
185
+
186
+ ### 3.7 Notifications (dictionary kind)
187
+
188
+ - Start with what happened: "Your file has been uploaded."
189
+ - Include timestamp context when relevant: "2 minutes ago".
190
+ - End with next action if applicable: "View file" or "Dismiss".
191
+ - Keep under 100 characters for mobile readability.
192
+
193
+ ---
194
+
195
+ ## 4. Content Lifecycle
196
+
197
+ ### 4.1 Draft Status
198
+
199
+ - Focus on completeness over polish.
200
+ - ALL required fields must have real values -- no placeholders.
201
+ - Optional fields may be empty but should be populated when possible.
202
+ - Drafts do not need final copy-editing but must be factually correct.
203
+ - Flag any fields the agent could not confidently populate.
204
+
205
+ ### 4.2 Review Status
206
+
207
+ - Vocabulary compliance: every term matches `vocabulary.json`.
208
+ - Tone consistency: matches `context.json` -> `conventions.tone` throughout.
209
+ - Factual accuracy: all claims, statistics, and references are verifiable.
210
+ - Cross-locale coverage: if entry exists in source locale, all target locales must have corresponding entries.
211
+ - Field constraint compliance: all values within min/max length, pattern, and type constraints.
212
+
213
+ ### 4.3 Published Status
214
+
215
+ ALL of the following must be true:
216
+
217
+ - Every required field is populated with final content.
218
+ - Every supported locale has a complete translation.
219
+ - Zero placeholder text anywhere in the entry.
220
+ - All relation fields reference existing, published entries.
221
+ - SEO fields (title, description, slug) are populated and valid.
222
+ - Content passes tone and vocabulary checks.
223
+
224
+ ### 4.4 Archive Criteria
225
+
226
+ Move content to archived status when:
227
+
228
+ - It references deprecated features, APIs, or products.
229
+ - Dates or events referenced are more than 12 months past.
230
+ - The content has been superseded by a newer entry.
231
+ - Statistics or data points are outdated and cannot be updated.
232
+
233
+ Never delete content. Archive it. Deletion is a manual human decision.
234
+
235
+ ---
236
+
237
+ ## 5. Contentrain-Specific Rules
238
+
239
+ ### 5.1 System-Managed Fields
240
+
241
+ NEVER write to these fields -- they are managed by the system:
242
+
243
+ - `id` -- auto-generated unique identifier
244
+ - `createdAt` -- set on creation
245
+ - `updatedAt` -- set on every save
246
+ - `status` -- managed through workflow transitions
247
+ - `order` -- managed through UI reordering
248
+
249
+ If a write payload includes any system field, remove it before saving.
250
+
251
+ ### 5.2 Metadata Directory
252
+
253
+ - NEVER write to `.contentrain/meta/` -- all metadata files are system-managed.
254
+ - NEVER modify `.contentrain/models/` directly -- use MCP tools.
255
+ - Read these directories for context, but treat them as read-only.
256
+
257
+ ### 5.3 Vocabulary Usage
258
+
259
+ - Load `vocabulary.json` at the start of every content operation.
260
+ - Cross-reference every noun, verb, and technical term against the vocabulary.
261
+ - If a term is not in the vocabulary but should be, flag it for human review -- do not add it.
262
+ - Vocabulary applies across ALL entries, ALL collections, ALL locales.
263
+
264
+ ### 5.4 Model Field Constraints
265
+
266
+ Before writing any field value:
267
+
268
+ 1. Read the model definition from `.contentrain/models/`.
269
+ 2. Check `required` -- required fields must have non-empty values.
270
+ 3. Check `min` / `max` -- string length must be within bounds.
271
+ 4. Check `pattern` -- value must match regex if defined.
272
+ 5. Check `unique` -- value must not duplicate any existing entry in the collection.
273
+ 6. Check `options` -- if the field is an enum/select, value must be from the defined list.
274
+
275
+ Constraint violations must be fixed before saving. Never save invalid data.
276
+
277
+ ### 5.5 Collection Entry Consistency
278
+
279
+ - All entries within a collection must follow the same structural pattern.
280
+ - If existing entries use a specific content structure (e.g., all blog posts start with a hook), new entries must follow the same pattern.
281
+ - Before creating a new entry, read 2-3 existing entries to understand the established pattern.
282
+ - If no existing entries exist, follow the content type pattern defined in Section 3.
283
+
284
+ ---
285
+
286
+ ## Validation Checklist
287
+
288
+ Before committing any content, verify:
289
+
290
+ - [ ] Heading hierarchy is sequential (H1 -> H2 -> H3, no skips)
291
+ - [ ] Title is 50-60 characters, keyword-rich, unique
292
+ - [ ] Description is 120-160 characters, complete sentence, unique
293
+ - [ ] No placeholder text anywhere
294
+ - [ ] No duplicate content across entries
295
+ - [ ] Tone matches `context.json` configuration
296
+ - [ ] All terms match `vocabulary.json`
297
+ - [ ] All field constraints (length, pattern, required) are satisfied
298
+ - [ ] Content follows the correct content type pattern
299
+ - [ ] System fields are not included in write payload
@@ -0,0 +1,170 @@
1
+ ---
2
+ name: media
3
+ description: "Media asset rules: image optimization, video handling, file naming conventions"
4
+ ---
5
+
6
+ # Media Rules
7
+
8
+ These rules are MANDATORY for all AI agents creating or editing content in Contentrain projects.
9
+ Follow these guidelines when populating image, video, or file fields in any content model.
10
+
11
+ ---
12
+
13
+ ## Image Dimensions (Recommended)
14
+
15
+ 1. Use these standard dimensions unless the project's `context.json` specifies overrides:
16
+
17
+ | Purpose | Width | Height | Aspect Ratio |
18
+ |---|---|---|---|
19
+ | Hero / Banner | 1200px | 630px | ~1.91:1 |
20
+ | Thumbnail / Card | 400px | 300px | 4:3 |
21
+ | Avatar / Profile | 200px | 200px | 1:1 (square) |
22
+ | Icon | 64px or 128px | 64px or 128px | 1:1 (square) |
23
+ | Full-width content | 1200px | proportional | varies |
24
+ | Social share (og:image) | 1200px | 630px | 1.91:1 |
25
+
26
+ 2. Hero/banner dimensions (1200x630) double as optimal `og:image` dimensions for social sharing.
27
+
28
+ 3. All images MUST be usable at mobile widths. Minimum renderable width: **320px**. Do not provide images narrower than this.
29
+
30
+ 4. When a model defines `width` and `height` fields alongside an image field, populate them with the actual image dimensions to prevent layout shift.
31
+
32
+ ---
33
+
34
+ ## File Formats
35
+
36
+ 1. **WebP** is the preferred format for all web images. Use it as the default unless a specific reason requires another format.
37
+
38
+ 2. **PNG**: use only when transparency is required and SVG is not suitable.
39
+
40
+ 3. **JPEG/JPG**: acceptable for photographs when WebP is not available. Use quality 75-85 for a good compression/quality balance.
41
+
42
+ 4. **SVG**: REQUIRED for logos, icons, and any vector graphics. Do not rasterize vector content.
43
+
44
+ 5. **AVIF**: acceptable as a progressive enhancement for browsers that support it. Always provide a WebP or JPEG fallback.
45
+
46
+ 6. **GIF**: do NOT use for animations. Use MP4 video instead for better compression and performance. Static GIFs are acceptable but WebP is preferred.
47
+
48
+ 7. **Never use** these formats for web content: BMP, TIFF, RAW, PSD, AI, EPS. Convert to a web-safe format before storing.
49
+
50
+ ---
51
+
52
+ ## File Size Limits
53
+
54
+ 1. Enforce these maximum file sizes:
55
+
56
+ | Asset Type | Max Size |
57
+ |---|---|
58
+ | Hero / Banner image | 200 KB |
59
+ | Thumbnail | 50 KB |
60
+ | Avatar / Icon | 30 KB |
61
+ | Content image | 150 KB |
62
+ | SVG file | 50 KB |
63
+ | Video poster image | 100 KB |
64
+
65
+ 2. **Total images per page**: aim for under **1 MB combined**. Flag content entries that reference more than 1 MB of images.
66
+
67
+ 3. If an image exceeds the size limit, instruct the user to compress or resize it before storing. Do not silently accept oversized files.
68
+
69
+ 4. SVG files SHOULD be optimized (e.g., with SVGO) to remove editor metadata, comments, and unnecessary attributes.
70
+
71
+ ---
72
+
73
+ ## File Naming Convention
74
+
75
+ 1. Use **kebab-case** for all media file names: lowercase, words separated by hyphens.
76
+
77
+ 2. File names MUST be **descriptive** — include context and subject:
78
+ - GOOD: `homepage-hero-banner.webp`, `blog-author-jane-doe.jpg`, `product-dashboard-preview.webp`
79
+ - BAD: `IMG_4523.jpg`, `photo1.png`, `untitled.webp`, `Screenshot 2024-01-15.png`, `image.jpg`
80
+
81
+ 3. When providing multiple sizes of the same image, include dimensions in the filename:
82
+ - `hero-1200x630.webp`, `hero-600x315.webp`
83
+ - Or use size suffixes: `hero-lg.webp`, `hero-md.webp`, `hero-sm.webp`
84
+
85
+ 4. Allowed characters in file names: lowercase letters (`a-z`), digits (`0-9`), hyphens (`-`), and a single dot before the extension. No spaces, underscores, or special characters.
86
+
87
+ 5. File extensions MUST be lowercase: `.webp` not `.WebP`, `.jpg` not `.JPG`.
88
+
89
+ ---
90
+
91
+ ## Alt Text Pairing
92
+
93
+ 1. Every content model with an `image` field SHOULD define a companion `image_alt` field (type: `string`). If the model does not have one, request that it be added.
94
+
95
+ 2. When both `image` and `image_alt` fields exist, ALWAYS populate both. Never leave `image_alt` empty unless the image is decorative (set to `""`).
96
+
97
+ 3. If no dedicated alt text field exists, include alt text guidance in the image field's `description` metadata so future content editors know to provide it.
98
+
99
+ 4. In document/markdown models, always use the full image syntax with alt text: `![descriptive alt text](path/to/image.webp)`. Never use `![](path)`.
100
+
101
+ 5. See `accessibility-rules.md` for detailed alt text writing guidelines.
102
+
103
+ ---
104
+
105
+ ## Video Guidelines
106
+
107
+ 1. **Format**: MP4 with H.264 codec for maximum browser compatibility. WebM (VP9) is acceptable as a secondary format.
108
+
109
+ 2. Every video MUST have a **poster/thumbnail image**. If the model has a `poster` or `thumbnail` field, populate it. The poster image follows the same format and size rules as other images.
110
+
111
+ 3. If the model defines a `duration` field, populate it in seconds (integer). This helps the frontend display duration badges and improves accessibility.
112
+
113
+ 4. Every video MUST reference a transcript or caption:
114
+ - A `transcript_url` field pointing to a text/VTT file
115
+ - A relation to a document entry containing the transcript
116
+ - Or inline transcript in an adjacent richtext/markdown field
117
+
118
+ 5. **Max file size** for self-hosted embedded video: **50 MB**. For larger videos, use external hosting.
119
+
120
+ 6. Prefer **external hosting** (YouTube, Vimeo, or CDN) for videos over 50 MB. Store the external URL in a `url` type field, not the video binary.
121
+
122
+ 7. Do not auto-play videos with audio. If the model has an `autoplay` field, set it to `false` by default.
123
+
124
+ ---
125
+
126
+ ## Asset Organization
127
+
128
+ 1. All media MUST be stored under the path defined in `config.json > assets_path`. The default is `.contentrain/assets/`.
129
+
130
+ 2. Organize assets using ONE of these conventions per project (check existing structure first):
131
+
132
+ **By domain:**
133
+ ```
134
+ assets/blog/
135
+ assets/team/
136
+ assets/products/
137
+ assets/marketing/
138
+ ```
139
+
140
+ **By type:**
141
+ ```
142
+ assets/images/
143
+ assets/videos/
144
+ assets/documents/
145
+ ```
146
+
147
+ 3. Check the existing asset directory structure before adding new files. Follow the established convention. Do not mix conventions within a project.
148
+
149
+ 4. Reference all media with **relative paths from the project root**:
150
+ - GOOD: `.contentrain/assets/blog/post-hero.webp`
151
+ - BAD: `/Users/jane/project/.contentrain/assets/blog/post-hero.webp`
152
+
153
+ 5. Do not create deeply nested directories (max 3 levels under `assets/`). Deep nesting makes paths fragile and hard to manage.
154
+
155
+ ---
156
+
157
+ ## Responsive Images
158
+
159
+ 1. When the content model supports multiple image sizes, provide variants for:
160
+ - **Small** (mobile): 320-768px wide
161
+ - **Medium** (tablet): 768-1024px wide
162
+ - **Large** (desktop): 1024px+ wide
163
+
164
+ 2. Use descriptive size suffixes in filenames: `-sm`, `-md`, `-lg` or explicit dimensions (`-400w`, `-800w`, `-1200w`).
165
+
166
+ 3. Always provide at least the **largest size**. Smaller sizes are recommended but optional — CDN or image optimization services can generate them from the original.
167
+
168
+ 4. If the model has a single `image` field (no responsive variants), provide the largest recommended size. The frontend is responsible for responsive rendering.
169
+
170
+ 5. Store the original/largest image. Never store only a downscaled version — you lose the ability to generate other sizes later.
@@ -0,0 +1,229 @@
1
+ ---
2
+ name: seo
3
+ description: "SEO optimization rules for content fields, meta tags, and structured data"
4
+ ---
5
+
6
+ # SEO Rules
7
+
8
+ These rules govern search engine optimization for all content managed through Contentrain.
9
+ Apply these rules to every content entry that produces a public-facing page.
10
+
11
+ ---
12
+
13
+ ## 1. Page Titles
14
+
15
+ ### 1.1 Length and Format
16
+
17
+ - Length: 50-60 characters including spaces. Google truncates titles beyond ~60 characters.
18
+ - Measure character count before saving. Truncated titles harm click-through rates.
19
+ - No ALL CAPS titles. Use sentence case or title case per project convention.
20
+ - No excessive punctuation: no `!!!`, no `???`, no `...` in titles.
21
+ - No emoji in titles unless explicitly configured in `context.json`.
22
+
23
+ ### 1.2 Keyword Placement
24
+
25
+ - Place the primary keyword within the first 30 characters.
26
+ - Structure: `Primary Keyword Phrase | Brand Name` or `Primary Keyword Phrase -- Brand Name`.
27
+ - Acceptable separators: ` | `, ` -- `, ` - `. Pick one and use it consistently across all entries.
28
+ - The keyword must read naturally -- no keyword stuffing.
29
+ - GOOD: "Deploy Node.js to Production | Acme Docs"
30
+ - BAD: "Node.js Deploy Node Production Deployment | Acme"
31
+
32
+ ### 1.3 Uniqueness
33
+
34
+ - Every entry in a collection MUST have a unique title.
35
+ - Before saving, query existing entries and confirm no title collision.
36
+ - Titles across collections should also be unique when they produce public pages.
37
+
38
+ ---
39
+
40
+ ## 2. Meta Descriptions
41
+
42
+ ### 2.1 Length and Format
43
+
44
+ - Length: 120-155 characters including spaces.
45
+ - Must be a complete sentence or two short sentences.
46
+ - End with a period.
47
+ - No keyword stuffing -- write for humans, not crawlers.
48
+
49
+ ### 2.2 Content Requirements
50
+
51
+ - Include a clear value proposition or call-to-action.
52
+ - GOOD: "Learn how to set up CI/CD for your Node.js project in 10 minutes. Step-by-step guide with examples."
53
+ - BAD: "CI/CD Node.js setup guide tutorial deployment continuous integration."
54
+ - Must differ from the page title -- do not repeat the title as the description.
55
+ - Must be unique per entry. No two entries may share the same meta description.
56
+
57
+ ### 2.3 What to Avoid
58
+
59
+ - No quotes or special characters that break HTML meta tags: avoid `"`, `<`, `>`.
60
+ - No "Click here to learn more" -- search engines ignore generic CTAs.
61
+ - No date references that will become stale (prefer "latest" over "2024").
62
+
63
+ ---
64
+
65
+ ## 3. Slugs
66
+
67
+ ### 3.1 Format
68
+
69
+ - Lowercase only. No uppercase characters.
70
+ - Words separated by hyphens (`-`). No underscores, no spaces, no dots.
71
+ - No special characters: only `a-z`, `0-9`, and `-`.
72
+ - No consecutive hyphens (`--`). No leading or trailing hyphens.
73
+
74
+ ### 3.2 Length and Content
75
+
76
+ - Optimal: 3-5 words.
77
+ - Maximum: 60 characters.
78
+ - Remove stop words (`the`, `a`, `an`, `is`, `of`, `and`, `or`, `in`, `to`) unless removing them changes meaning.
79
+ - "how-to-deploy-node" -> "deploy-node" is acceptable.
80
+ - "state-of-the-art" -> keep as-is because meaning changes if shortened.
81
+
82
+ ### 3.3 Stability
83
+
84
+ - NEVER change a slug on a published entry. Changing slugs breaks existing links, bookmarks, and search engine indexing.
85
+ - If a slug must change, the human must set up a redirect. The agent must not change published slugs without explicit human instruction.
86
+ - Draft entries may have their slugs changed freely before first publication.
87
+
88
+ ### 3.4 Locale Consistency
89
+
90
+ - Use the same slug value across all locales for the same entry.
91
+ - Do NOT translate slugs. Slugs are identifiers, not content.
92
+ - Example: the slug `deploy-node` remains `deploy-node` in `en`, `tr`, `de`, and all other locales.
93
+
94
+ ---
95
+
96
+ ## 4. Heading Structure
97
+
98
+ ### 4.1 H1 Rule
99
+
100
+ - Exactly one H1 per page. The H1 is the entry title or the primary heading.
101
+ - The H1 should contain the primary keyword naturally.
102
+ - Do not duplicate the H1 text elsewhere on the page.
103
+
104
+ ### 4.2 Subheading Keywords
105
+
106
+ - Include relevant keywords in H2 and H3 headings where natural.
107
+ - Do not force keywords into every heading. Clarity takes priority over keyword density.
108
+ - Use question-format headings for FAQ-style content: "How do I reset my password?"
109
+
110
+ ### 4.3 Hierarchy Reflects Content
111
+
112
+ - Heading levels must reflect the logical structure of the content.
113
+ - Do not use H3 because it renders smaller -- use CSS for styling, headings for structure.
114
+ - Every heading must have content beneath it. No empty sections.
115
+ - Do not place two headings consecutively without content between them.
116
+
117
+ ---
118
+
119
+ ## 5. Images and Alt Text
120
+
121
+ ### 5.1 Alt Text Requirements
122
+
123
+ - Every `image` field that displays on a public page MUST have corresponding alt text.
124
+ - Describe the image content and its context: "Dashboard showing monthly revenue chart with 15% growth indicator."
125
+ - Maximum length: 125 characters.
126
+ - Do not start with "Image of", "Photo of", "Picture of" -- describe directly.
127
+
128
+ ### 5.2 Decorative Images
129
+
130
+ - If an image is purely decorative (visual separator, background pattern), set alt text to an empty string (`""`).
131
+ - Do not omit the alt field entirely -- explicitly set it to empty.
132
+
133
+ ### 5.3 Keywords in Alt Text
134
+
135
+ - Include relevant keywords naturally when they describe the image.
136
+ - Do not stuff keywords: "Node.js Node deployment Node server Node production" is forbidden.
137
+ - The alt text must accurately describe what is in the image.
138
+
139
+ ### 5.4 Image File Names
140
+
141
+ - When the agent controls the image file name, use descriptive, hyphenated names.
142
+ - GOOD: `revenue-dashboard-chart.png`
143
+ - BAD: `IMG_2847.png`, `screenshot.png`, `image1.png`
144
+
145
+ ---
146
+
147
+ ## 6. Open Graph and Social Media
148
+
149
+ ### 6.1 Open Graph Tags
150
+
151
+ When OG fields exist in the model, populate them:
152
+
153
+ | Field | Max Length | Requirement |
154
+ |---|---|---|
155
+ | `og:title` | 60 characters | Concise version of the page title |
156
+ | `og:description` | 200 characters | Slightly longer than meta description, conversational |
157
+ | `og:image` | -- | 1200x630 pixels recommended, must be absolute URL |
158
+ | `og:type` | -- | `article` for blog/docs, `website` for landing pages |
159
+
160
+ ### 6.2 Twitter Card
161
+
162
+ - Use `summary_large_image` for content with strong visual elements.
163
+ - Use `summary` for text-focused content.
164
+ - Twitter title and description may differ from OG -- optimize for each platform.
165
+
166
+ ### 6.3 Fallback
167
+
168
+ - If OG-specific fields are absent, the system uses the standard title and description.
169
+ - Ensure the standard title and description are suitable for social sharing.
170
+
171
+ ---
172
+
173
+ ## 7. Internal Linking
174
+
175
+ ### 7.1 Relation Fields
176
+
177
+ - Use Contentrain `relation` and `relations` model fields for cross-references between entries.
178
+ - Prefer structured relations over hardcoded links in body content.
179
+ - Structured relations are maintainable -- if a slug changes, relations still resolve.
180
+
181
+ ### 7.2 Bidirectional Relations
182
+
183
+ - When Entry A references Entry B, check if Entry B should reference Entry A.
184
+ - Example: if a blog post links to a product, the product's "related articles" should include that blog post.
185
+ - The agent should suggest bidirectional relations but not create them without confirmation.
186
+
187
+ ### 7.3 Manual Links in Body Content
188
+
189
+ - If the model does not have relation fields and links must be in body text, use relative paths.
190
+ - Verify that linked entries exist before saving.
191
+ - Do not link to draft or archived entries from published content.
192
+
193
+ ---
194
+
195
+ ## 8. URL and Canonical Rules
196
+
197
+ ### 8.1 Slug Patterns
198
+
199
+ - All entries in a collection must follow the same slug pattern.
200
+ - If existing entries use `verb-noun` format (e.g., `deploy-app`, `configure-server`), new entries must follow the same pattern.
201
+ - Check existing entries before generating a slug for a new entry.
202
+
203
+ ### 8.2 Multi-Locale URLs
204
+
205
+ - Same slug across all locales (see Section 3.4).
206
+ - Locale prefix is handled by the frontend routing, not by the content slug.
207
+ - Example: `/en/deploy-node` and `/tr/deploy-node` share the slug `deploy-node`.
208
+
209
+ ### 8.3 Trailing Slashes
210
+
211
+ - The agent does not control trailing slash behavior -- this is a frontend routing concern.
212
+ - Ensure slug values do not include leading or trailing slashes.
213
+
214
+ ---
215
+
216
+ ## Validation Checklist
217
+
218
+ Before committing any content with SEO impact, verify:
219
+
220
+ - [ ] Title is 50-60 characters, primary keyword near start, unique
221
+ - [ ] Meta description is 120-155 characters, complete sentence, unique
222
+ - [ ] Slug is lowercase, hyphenated, 3-5 words, no special characters
223
+ - [ ] Published slugs have not been changed
224
+ - [ ] Slugs are identical across all locales for the same entry
225
+ - [ ] One H1 per page, sequential heading hierarchy
226
+ - [ ] All images have descriptive alt text (max 125 chars) or empty string for decorative
227
+ - [ ] OG fields populated if model supports them
228
+ - [ ] Relation fields used for internal cross-references
229
+ - [ ] No keyword stuffing in titles, descriptions, headings, or alt text