> ## Documentation Index
> Fetch the complete documentation index at: https://docs.hiveku.com/llms.txt
> Use this file to discover all available pages before exploring further.

# How AI Agents Use the CMS

> Hiveku's AI can scaffold a manifest, propose collections, write entries, and refactor your components to read from the CMS

The Hiveku CMS is designed to be edited by both humans and the AI. The AI has a small set of tools for reading and writing the manifest, listing entries, and reading/writing/deleting them — which means you can describe content changes in plain English and let the AI carry them out.

This page covers what the AI can do, the tools it uses (high level), and how to prompt it well for content tasks.

## What the AI Can Do

<CardGroup cols={2}>
  <Card title="Scaffold a manifest" icon="file-pen">
    From an empty project, propose a complete manifest based on what your site needs
  </Card>

  <Card title="Add or change collections" icon="plus">
    Add new collections, add fields to existing ones, change field types
  </Card>

  <Card title="Write and edit entries" icon="pencil">
    Create entries from a description, an existing file, or a paste of content
  </Card>

  <Card title="Refactor components" icon="code-merge">
    Replace hardcoded content in React components with reads from the CMS
  </Card>

  <Card title="Bulk operations" icon="layer-group">
    Migrate from CSV/JSON, normalize data, rename slugs, deduplicate
  </Card>

  <Card title="Schema migrations" icon="arrows-rotate">
    Rename fields and migrate existing entry data to the new shape
  </Card>
</CardGroup>

## The Tools the AI Uses

The AI has six tools dedicated to the CMS, exposed through the project's MCP server. You won't call them directly, but knowing they exist helps you prompt the AI more precisely.

| Tool                         | What it does                                                                      |
| ---------------------------- | --------------------------------------------------------------------------------- |
| `manage_cms_scaffold`        | Create a fresh `hiveku.cms.json` (and optional starter content) for a new project |
| `manage_cms_read_manifest`   | Read the current manifest                                                         |
| `manage_cms_update_manifest` | Update the manifest — add, remove, or modify collections and fields               |
| `manage_cms_list_entries`    | List entries in a collection (with search, filter, sort)                          |
| `manage_cms_read_entry`      | Read one entry's contents                                                         |
| `manage_cms_write_entry`     | Create or update one entry                                                        |
| `manage_cms_delete_entry`    | Remove an entry                                                                   |

Each tool runs the same validation as the CMS panel, so the AI can't write an invalid entry or break the manifest schema. Failed writes return error messages the AI can use to retry or ask you for clarification.

## Prompting Patterns

### Set up a CMS for a new project

Best when starting from scratch or with a minimal site:

```
Set up a CMS for this site. We'll need a blog with posts, an author
collection that the blog references, and a testimonials collection.
```

The AI will:

1. Read the project to understand the framework and existing routes
2. Propose a manifest with the three collections and sensible fields
3. Confirm with you
4. Save the manifest
5. Optionally seed each collection with one example entry

### Migrate hardcoded content to the CMS

Best when you have content embedded in code that you want to extract:

```
Look at app/blog/page.tsx — it has 12 hardcoded blog posts in an
array. Move them into a blog collection in the CMS, and refactor
the page to read from the CMS instead.
```

The AI will:

1. Read the file and extract the hardcoded data
2. Propose a `blog` collection schema based on the shape of the data
3. Confirm with you
4. Add the collection to the manifest
5. Write one entry per post
6. Refactor the React component to import from the CMS
7. Show you a diff and let you verify

See [Migrate an Existing Site to the CMS](/how-tos/migrate-site-to-cms) for the full walkthrough.

### Write a new entry

Best for one-off entries with rich content:

```
Add a blog post titled "Why we switched to Hiveku" — make it 500
words, professional but conversational tone. Tag it as "case-study"
and "engineering". Set publishedAt to today.
```

The AI will draft the post, write it as an MDX file, and (optionally) show you a preview before saving.

### Bulk edits

Best when many entries need the same change:

```
For all blog posts published before 2025, set status to "archived"
and add the tag "legacy".
```

The AI will list matching entries, confirm the count, and apply the change in a batch.

### Schema changes

Best when you need to add a field across an existing collection:

```
Add a "readingTime" field (integer, minutes) to the blog collection.
Calculate it for every existing post (~200 words per minute) and
backfill the value.
```

The AI will:

1. Update the manifest
2. Read each existing entry, compute the reading time, write it back
3. Report how many entries were updated

### Refactor a component to use the CMS

Best when you want existing UI to start reading from a collection:

```
Refactor app/team/page.tsx to read from the team collection in the
CMS. Right now the team members are hardcoded in a JSX array.
```

The AI will rewrite the component to import from the CMS, type the data correctly, and remove the hardcoded array.

## Prompting Tips

A few patterns that consistently get better results:

* **Anchor the AI to a file or feature.** "Look at `app/blog/page.tsx`" beats "Migrate my blog" because the AI doesn't have to guess where the content lives.
* **Specify the schema if you know it.** If you already know your blog needs `title`, `excerpt`, `publishedAt`, `body`, `tags`, `author`, say so. The AI will fill in sensible defaults but it can't read your mind.
* **Do one collection at a time.** A single migration is easier to verify than three at once. The AI can chain them, but you get cleaner diffs from sequential prompts.
* **Ask for a confirmation first.** "Plan the migration but don't write anything yet." Then after you've reviewed the plan, "Now do it."
* **Use natural language for filters.** "Posts from last quarter," "products under \$50," "FAQs in the billing category" — the AI translates these into list filters automatically.

## Trust Boundaries

A few things the AI is conservative about:

* **Deletes.** The AI confirms before deleting any entry. You can override this with explicit prompts ("delete every post tagged 'old' without asking").
* **Schema removals.** Removing a field from the manifest is non-destructive (data stays in the file), but the AI calls it out in the diff so you don't lose track.
* **Renames that orphan data.** Renaming a field in the manifest doesn't move data on disk. The AI flags this and offers to write a migration.
* **Reference cascades.** Deleting an entry that's referenced by others will leave dangling references. The AI warns and offers to clean them up.

## Inspecting What the AI Did

Every CMS write the AI makes goes through the same versioning system as your manual edits. After any AI-driven change:

* Open the CMS panel — the new or modified entries are in the entry list
* Click any entry → three-dot menu → **Version history** to see the AI-authored snapshot
* Open the file in the code editor to inspect the raw MDX/JSON
* Click **Restore this version** if you want to roll back

## Example: Migrating a Site With AI

A condensed version of the full [migration guide](/how-tos/migrate-site-to-cms):

<Steps>
  <Step title="Describe the source">
    *"My homepage has a hardcoded `<TestimonialsSection />` with 6 testimonials embedded in JSX. I want non-developers to be able to edit them."*
  </Step>

  <Step title="Let the AI plan">
    *"Plan the migration — propose a schema and show me the field shape."*

    The AI returns a draft manifest entry with `name`, `company`, `quote`, `avatar`, `featured` fields.
  </Step>

  <Step title="Approve and execute">
    *"Looks good. Add the collection, migrate the 6 testimonials, and refactor the component to read from the CMS."*

    The AI:

    * Updates `hiveku.cms.json` with the `testimonials` collection
    * Writes 6 JSON files to `content/testimonials/`
    * Rewrites `<TestimonialsSection />` to read the collection
    * Deploys a preview
  </Step>

  <Step title="Verify in the CMS panel">
    Open the panel, switch to the testimonials collection, edit one. The change appears in the live preview.
  </Step>
</Steps>

## What's Next?

<CardGroup cols={2}>
  <Card title="Migrate a Site" icon="arrow-right-arrow-left" href="/how-tos/migrate-site-to-cms">
    Full walkthrough for moving hardcoded content into the CMS
  </Card>

  <Card title="Initialize Your CMS" icon="rocket" href="/how-tos/initialize-cms">
    First-time setup
  </Card>

  <Card title="Editing Content" icon="pencil" href="/cms/editing-content">
    The CMS panel for human editors
  </Card>

  <Card title="The Manifest" icon="file-code" href="/cms/manifest">
    What the AI is reading and writing
  </Card>
</CardGroup>
