heymegabyte/agent-skills / 06-build-and-slice-loop
build-and-slice-loop
VerifiedUse when implementing features or streaming OnePrompt site builds. Complete vertical slices with real content, strict TypeScript and Zod. Parallel section/data work, deterministic assembly, granular patches and immediate valid previews.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 7.2 KB |
| admin-dashboard.md | markdown | 5.5 KB |
| ai-chat-widget.md | markdown | 6.0 KB |
| blog-and-content-engine.md | markdown | 6.2 KB |
| build-breaking-rules.md | markdown | 7.4 KB |
| chat-native-dashboard.md | markdown | 3.6 KB |
| contact-forms-and-endpoints.md | markdown | 6.7 KB |
| copilot-and-ai-features.md | markdown | 7.4 KB |
| custom-error-pages.md | markdown | 4.5 KB |
| data-tables.md | markdown | 7.7 KB |
| domain-provisioning.md | markdown | 4.6 KB |
| easter-eggs.md | markdown | 4.7 KB |
| empty-states-and-loading.md | markdown | 5.7 KB |
| file-uploads-and-storage.md | markdown | 6.7 KB |
| internationalization.md | markdown | 4.3 KB |
| keyboard-shortcuts-and-command-palette.md | markdown | 6.7 KB |
| microcopy-library.md | markdown | 8.0 KB |
| notification-center.md | markdown | 8.4 KB |
| onboarding-and-first-run.md | markdown | 5.0 KB |
| pre-digested-builds.md | markdown | 3.6 KB |
| pwa-kit.md | markdown | 6.8 KB |
| realtime-and-websockets.md | markdown | 7.2 KB |
| rich-text-editor.md | markdown | 7.4 KB |
| site-search.md | markdown | 4.0 KB |
| stripe-first-donations.md | markdown | 10.7 KB |
| web-manifest-system.md | markdown | 11.9 KB |
| webhook-system.md | markdown | 9.5 KB |
site-search.md
View on GitHub---
name: "Site Search"
version: "2.0.0"
updated: "2026-04-23"
description: "Cloudflare AI Search (formerly AutoRAG): hybrid semantic + keyword search, dynamic instances, relevance boosting, multi-tenant via folder-prefix filtering or dedicated namespaces, built-in MCP endpoint for AI agents, Cmd+K modal UI, auto-indexing at deploy."
---
# Site Search (Cloudflare AI Search)
**MANDATORY for every product.** CF AI Search is free, zero-infrastructure, makes products feel premium.
## Wrangler Config
```jsonc
{ "ai_search_namespaces": [{ "binding": "AI_SEARCH", "namespace": "default" }] }
```
## Instance Creation
```typescript
const instance = await env.AI_SEARCH.create({
id: "projectsites-shared",
index_method: { vector: true, keyword: true },
fusion_method: "rrf",
indexing_options: { keyword_tokenizer: "porter" },
retrieval_options: { keyword_match_mode: "and" },
});
```
## Multi-Tenant: Folder-Prefix Isolation
```typescript
// Shared instance, filter by site prefix
const results = await instance.search({
messages: [{ role: "user", content: query }],
filters: { folder: { $gte: `${siteId}/`, $lt: `${siteId}0` } },
});
```
Range query ensures `site-abc123/` matches but `site-abc1234/` does not.
### Tier Matrix
| Tier | Strategy | Max Pages |
|------|----------|-----------|
| Free | Shared, folder-prefix | 50 |
| Standard | Shared, folder-prefix | 500 |
| Premium | Dedicated instance | 10,000 |
| Enterprise | Dedicated namespace | Unlimited |
## Search API
```typescript
app.get('/api/search', zValidator('query', searchSchema), async (c) => {
const { q, siteId, limit } = c.req.valid('query');
const isPremium = (await c.env.KV.get(`site:${siteId}:config`, 'json'))?.tier === 'premium';
const instance = isPremium ? env.AI_SEARCH.get(`site-${siteId}`) : env.AI_SEARCH.get("projectsites-shared");
const results = await instance.search({
messages: [{ role: "user", content: q }],
...(isPremium ? {} : { filters: { folder: { $gte: `${siteId}/`, $lt: `${siteId}0` } } }),
ai_search_options: { max_num_results: limit },
});
return c.json({ results: results.results.map((r: any) => ({ url: r.metadata?.url, title: r.metadata?.title, snippet: r.content?.substring(0, 200), score: r.score })) });
});
```
## MCP Endpoint for AI Agents
Expose per-tenant search as MCP tool at `/api/mcp/:siteId`. Returns tool definition + handles tool calls with tenant-scoped search.
## Auto-Index at Deploy
```typescript
async function indexSitePages(env: Env, siteId: string, pages: SitePage[]) {
const isPremium = (await env.KV.get(`site:${siteId}:config`, 'json'))?.tier === 'premium';
const instance = isPremium ? env.AI_SEARCH.get(`site-${siteId}`) : env.AI_SEARCH.get('projectsites-shared');
for (const page of pages) {
const itemId = isPremium ? `pages/${page.slug}` : `${siteId}/pages/${page.slug}`;
await instance.items.uploadAndPoll(itemId, page.content, {
metadata: { title: page.title, url: page.url, description: page.description, updatedAt: new Date().toISOString() },
});
}
}
```
## Cmd+K UI
- Keyboard — Cmd/Ctrl+K opens, Escape closes
- Debounced 200ms search on input
- Arrow keys navigate results
- Enter opens
- Shows loading state, empty state
## Cross-Instance Search (Premium)
```typescript
await env.AI_SEARCH.search({ messages: [...], ai_search_options: { instance_ids: ["site-abc", "site-def"] } });
```
## Relevance Boosting
```typescript
boost: [{ field: "timestamp", method: "recency", weight: 1.2 }, { field: "category", method: "match", value: "docs", weight: 1.5 }]
```
## Migration from D1 LIKE
1. Keep same `/api/search` endpoint
2. Replace D1 query with AI Search
3. Add `data-site-id` to `<html>`
4. Run `indexSitePages` on first deploy
5. Remove `search_index` table after verification
## Ownership
- **Owns** — search indexing, multi-tenant isolation, search API, Cmd+K UI, MCP endpoint, auto-indexing, cross-instance search
- **Never owns** — AI chat/conversational (→43), general MCP (→52), deployment (→08)
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| receiving-code-reviewobra/superpowersUse when receiving code review feedback, before implementing suggestions, especially if feedback seems unclear or technically questionable - requires technical rigor and verification, not performative agreement or blind implementation | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| requesting-code-reviewobra/superpowersUse when completing tasks, implementing major features, or before merging to verify work meets requirements | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| using-git-worktreesobra/superpowersUse when starting feature work that needs isolation from current workspace or before executing implementation plans - ensures an isolated workspace exists via native tools or git worktree fallback | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| verification-before-completionobra/superpowersUse when about to claim work is complete, fixed, or passing, before committing or creating PRs - requires running verification commands and confirming output before making any success claims; evidence before assertions always | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |