Skill: garchi-render-content
Scope
- ✅ Build or improve the code needed to fetch and render Garchi CMS content (pages, sections, data items).
- ✅ Integrate Garchi CMS into an existing codebase without breaking conventions.
- ❌ Do not manage CMS content (create pages/sections/assets/templates) unless the user explicitly asks. Prefer MCP tools for CMS actions.
Always (non-negotiable rules)
-
Preserve Visual Editor attributes
- For every section component, forward unknown/extra props/attributes to the root element (outermost wrapper).
- Framework-agnostic rule: “Unknown attributes must not be dropped; attach them to the root/host element.”
- Patterns:
- React/Preact/Solid: spread
...otheron root - Vue:
v-bind="$attrs"on root - Svelte: spread
...$$restPropson root - Angular: preserve/pass through host attributes; do not strip unknown attrs
- Web Components: keep attrs on host or forward to outer wrapper
- Laravel Blade: ensure attributes are passed to the root element of the section component {{ $attributes->merge()}}
- React/Preact/Solid: spread
-
Do not modify reference snippets/docs
- Treat code-snippets and provided examples as reference. Do not rewrite them unless asked.
-
Keep codebase conventions
- Follow existing linting, formatting, naming, and folder conventions.
- Avoid large refactors unless requested.
Initial checks (do first)
- Read Garchi CMS documentation (mandatory).
- Review OpenAPI spec (mandatory).
- Read Node SDK documentation if using Node (optional but recommended).
- Read PHP SDK documentation if using PHP (optional but recommended).
- Identify the target stack and project type:
- Is this a starter-kit project or an existing codebase?
- Confirm configuration:
- API key + Space UID available in
.env/ config - If preview mode is needed: preview token config exists
- API key + Space UID available in
Recommended implementation workflow
A) Choose access method
- Prefer starter kits for fresh projects. Ask user for the choice of available stack, next, nuxt, and laravel.
- Prefer SDKs where available (Node SDK / PHP SDK).
- If using raw API, create a small service layer (DRY/SOLID, typed, reusable). Raw API call should be made from server environment and is doesn't support client side calls. Use the OpenAPI spec for reference.
B) Build the rendering pipeline
- Fetch page/data item from server-side (SSR/server runtime).
- Render sections via a single section renderer (mapper).
- Each section maps to a reusable component.
- Support nested sections (
subsections) if present.
C) Quality + safety
- Sanitize HTML before rendering (XSS).
- Handle errors gracefully (notFound, fallback UI).
- Use stable keys (prefer section id/uid over array index when available).
- Add basic logging for missing components or invalid payload shapes.
Definition of Done (what “complete” means)
- Pages/data items render correctly in the chosen stack.
- Visual Editor attributes are preserved on all section components.
- Preview/draft mode works (if required).
- Errors are handled without infinite retries/loops.
- HTML content is sanitized where applicable.
Loop prevention (stop conditions)
- Do not retry the same failing operation more than 2 times.
- After an update/fetch, verify state once; if still incorrect, stop and report what’s missing.