@mikulgohil/ai-kit 1.9.0 → 1.11.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.
- package/README.md +33 -9
- package/agents/build-resolver.md +2 -0
- package/agents/e2e-runner.md +2 -0
- package/agents/migration-specialist.md +3 -1
- package/agents/refactor-cleaner.md +2 -0
- package/commands/fetch-docs.md +90 -0
- package/dist/index.js +647 -244
- package/dist/index.js.map +1 -1
- package/guides/getting-started.md +25 -1
- package/guides/token-saving-tips.md +15 -0
- package/package.json +8 -4
- package/templates/claude-md/base.md +25 -0
- package/templates/claude-md/nextjs-app-router.md +18 -1
- package/templates/claude-md/sitecore-xmc.md +2 -2
- package/templates/cursorrules/base.md +8 -0
- package/templates/cursorrules/nextjs-app-router.md +4 -1
- package/templates/cursorrules/sitecore-xmc.md +1 -1
|
@@ -68,10 +68,12 @@ Open any file and use Cmd+K or the chat panel. The `.cursorrules` file is automa
|
|
|
68
68
|
|
|
69
69
|
Hooks run automatically as you code — no action needed. Based on your selected profile:
|
|
70
70
|
|
|
71
|
+
- **Session init**: echoes your tech stack, scripts, and last scan date at every session start — the AI has full context immediately
|
|
71
72
|
- **Auto-format**: files are formatted on save (Prettier or Biome)
|
|
72
73
|
- **Type-check**: TypeScript errors caught after every edit
|
|
73
74
|
- **Console.log warning**: catches debug statements before commit
|
|
74
75
|
- **Git push safety**: reminder to review before pushing
|
|
76
|
+
- **Context re-echo**: after context compaction in long sessions, re-echoes tech stack
|
|
75
77
|
|
|
76
78
|
See `ai-kit/guides/hooks-and-agents.md` for details on profiles and customization.
|
|
77
79
|
|
|
@@ -103,7 +105,9 @@ Specialized AI assistants live in `.claude/agents/` and can be delegated to:
|
|
|
103
105
|
## CLI Commands
|
|
104
106
|
|
|
105
107
|
```bash
|
|
106
|
-
npx @mikulgohil/ai-kit update # Re-scan and update configs
|
|
108
|
+
npx @mikulgohil/ai-kit update # Re-scan and update configs (auto-backs up first)
|
|
109
|
+
npx @mikulgohil/ai-kit migrate # Adopt ai-kit in a project with existing CLAUDE.md
|
|
110
|
+
npx @mikulgohil/ai-kit rollback # Restore configs from a previous backup
|
|
107
111
|
npx @mikulgohil/ai-kit audit # Security & config health check
|
|
108
112
|
npx @mikulgohil/ai-kit doctor # Diagnose setup issues
|
|
109
113
|
npx @mikulgohil/ai-kit diff # Preview what would change on update
|
|
@@ -112,3 +116,23 @@ npx @mikulgohil/ai-kit tokens # Token usage and cost estimates
|
|
|
112
116
|
npx @mikulgohil/ai-kit export # Export to Windsurf, Aider, Cline
|
|
113
117
|
npx @mikulgohil/ai-kit reset # Remove all generated files
|
|
114
118
|
```
|
|
119
|
+
|
|
120
|
+
## Migrating an Existing Project
|
|
121
|
+
|
|
122
|
+
Already have a hand-written `CLAUDE.md` or `.cursorrules`? Use `migrate` instead of `init`:
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
npx @mikulgohil/ai-kit migrate # Preserves your custom rules, adds ai-kit sections
|
|
126
|
+
npx @mikulgohil/ai-kit migrate --dry-run # Preview what would change without writing
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
Your custom sections stay at the top of the file. AI Kit's generated rules go below in `AI-KIT:START/END` markers. Future `ai-kit update` commands only touch the marked section.
|
|
130
|
+
|
|
131
|
+
## Rolling Back
|
|
132
|
+
|
|
133
|
+
Every `ai-kit update` automatically backs up your current configs before writing. If something goes wrong:
|
|
134
|
+
|
|
135
|
+
```bash
|
|
136
|
+
npx @mikulgohil/ai-kit rollback # Pick from available backups
|
|
137
|
+
npx @mikulgohil/ai-kit rollback --latest # Restore most recent backup instantly
|
|
138
|
+
```
|
|
@@ -45,6 +45,21 @@ If the AI doesn't get it right in 2 attempts:
|
|
|
45
45
|
2. The task might be too complex for a single prompt
|
|
46
46
|
3. Take over manually — you'll save tokens and time
|
|
47
47
|
|
|
48
|
+
## Know Your Context Limits
|
|
49
|
+
|
|
50
|
+
Claude Code now supports up to **1M tokens of context** (Opus 4.6) with **64K default output** (128K ceiling). This is massive — but context still costs money.
|
|
51
|
+
|
|
52
|
+
| Model | Context Window | Default Output | Max Output |
|
|
53
|
+
|-------|---------------|----------------|------------|
|
|
54
|
+
| Opus 4.6 | 1M tokens | 64K tokens | 128K tokens |
|
|
55
|
+
| Sonnet 4.6 | 200K tokens | 64K tokens | 128K tokens |
|
|
56
|
+
|
|
57
|
+
### Use `/effort` to Control Token Spend
|
|
58
|
+
Claude Code's `/effort` command lets you set reasoning effort levels. For simple tasks, lower effort saves tokens. For complex architecture decisions, higher effort produces better results.
|
|
59
|
+
|
|
60
|
+
### Context Compaction
|
|
61
|
+
When conversations get long, Claude Code automatically compacts earlier context. The **PostCompact hook** fires after this happens — your AI Kit hooks use it to ensure important context survives compaction.
|
|
62
|
+
|
|
48
63
|
## CLAUDE.md Is Free Context
|
|
49
64
|
|
|
50
65
|
Your `CLAUDE.md` file is loaded automatically — everything in it gives the AI context without using your conversation tokens. That's why `ai-kit` generates it: better output from fewer tokens.
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikulgohil/ai-kit",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "AI-assisted development setup kit. Auto-detects your tech stack (Next.js, Sitecore XM Cloud, Optimizely SaaS CMS, Tailwind, TypeScript, Turborepo) and generates tailored CLAUDE.md, .cursorrules, hooks, agents, context modes, slash commands, design token rules, component registries, developer guides, and spec-first workflows.",
|
|
3
|
+
"version": "1.11.0",
|
|
4
|
+
"description": "AI-assisted development setup kit. Auto-detects your tech stack (Next.js, Sitecore XM Cloud, Optimizely SaaS CMS, Tailwind, TypeScript, Turborepo) and generates tailored CLAUDE.md, .cursorrules, hooks, agents, context modes, slash commands, design token rules, component registries, developer guides, and spec-first workflows. Migrate existing projects, auto-backup on update, and rollback support.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
7
7
|
"ai-kit": "./dist/index.js"
|
|
@@ -60,7 +60,11 @@
|
|
|
60
60
|
"extension-catalog",
|
|
61
61
|
"presets",
|
|
62
62
|
"constitution",
|
|
63
|
-
"spec-first"
|
|
63
|
+
"spec-first",
|
|
64
|
+
"migrate",
|
|
65
|
+
"rollback",
|
|
66
|
+
"backup",
|
|
67
|
+
"session-context"
|
|
64
68
|
],
|
|
65
69
|
"author": {
|
|
66
70
|
"name": "Mikul Gohil",
|
|
@@ -76,7 +80,7 @@
|
|
|
76
80
|
"url": "https://github.com/mikulgohil/ai-kit/issues"
|
|
77
81
|
},
|
|
78
82
|
"engines": {
|
|
79
|
-
"node": ">=
|
|
83
|
+
"node": ">=20.0.0"
|
|
80
84
|
},
|
|
81
85
|
"dependencies": {
|
|
82
86
|
"@inquirer/prompts": "^7.0.0",
|
|
@@ -105,6 +105,30 @@ These standards are enforced across all projects to ensure consistency.
|
|
|
105
105
|
- Pin dependency versions — avoid `^` or `~` for critical packages
|
|
106
106
|
- When adding a new dependency, note the reason in the component's doc file or PR description
|
|
107
107
|
|
|
108
|
+
## Documentation Verification
|
|
109
|
+
|
|
110
|
+
AI training data has a cutoff date. When working with framework APIs, **verify your knowledge is current** before writing code:
|
|
111
|
+
|
|
112
|
+
### When to Verify
|
|
113
|
+
- Using an API you haven't seen in this project's codebase
|
|
114
|
+
- Working with recently released features (Next.js 16+, Tailwind v4, Sitecore Content SDK v2.x)
|
|
115
|
+
- When you're unsure about an API signature, parameter order, or return type
|
|
116
|
+
- When a build error suggests an API doesn't exist or has changed
|
|
117
|
+
|
|
118
|
+
### How to Verify (in priority order)
|
|
119
|
+
1. **Check this project's code first** — existing implementations are the most reliable reference
|
|
120
|
+
2. **Use Context7 MCP** — if available, use `resolve-library-id` then `query-docs` to fetch current, version-specific documentation
|
|
121
|
+
3. **Use llms.txt endpoints** — fetch from official AI-friendly docs:
|
|
122
|
+
- Next.js: `https://nextjs.org/docs/llms-full.txt`
|
|
123
|
+
- Sitecore XM Cloud: check the project repo for `LLMs.txt`
|
|
124
|
+
4. **Use WebFetch** — fetch the specific docs page for the API in question
|
|
125
|
+
|
|
126
|
+
### Rules
|
|
127
|
+
- Do NOT guess at API signatures — look them up if unsure
|
|
128
|
+
- Do NOT assume a library API works the same as a previous version
|
|
129
|
+
- The code examples in this CLAUDE.md file are current and verified — prefer them over memory
|
|
130
|
+
- When you look something up, briefly note what you found so the developer knows the source
|
|
131
|
+
|
|
108
132
|
## Code Quality
|
|
109
133
|
- Match existing patterns, naming conventions, and file structure
|
|
110
134
|
- Keep changes minimal — don't refactor surrounding code unless asked
|
|
@@ -170,6 +194,7 @@ AI will auto-discover and apply these when your task matches. You can also invok
|
|
|
170
194
|
- `/document` — Generate documentation for existing code
|
|
171
195
|
- `/commit-msg` — Generate conventional commit message from staged changes
|
|
172
196
|
- `/env-setup` — Generate .env.example and validate environment variables
|
|
197
|
+
- `/fetch-docs` — Pre-load current docs for your tech stack (run at session start)
|
|
173
198
|
|
|
174
199
|
## Scripts
|
|
175
200
|
{{scripts}}
|
|
@@ -54,10 +54,27 @@ app/
|
|
|
54
54
|
- Use `revalidateTag(tag)` or `revalidatePath(path)` in Server Actions for on-demand ISR
|
|
55
55
|
- Tag fetches with `fetch(url, { next: { tags: ['posts'] } })` for targeted revalidation
|
|
56
56
|
|
|
57
|
+
## Turbopack (Next.js 16+)
|
|
58
|
+
- Turbopack is stable and production-ready — use `next dev --turbopack` for ~4x faster dev startup
|
|
59
|
+
- Server Fast Refresh: instant HMR for server-side changes (no full reload)
|
|
60
|
+
- Supports SRI (Subresource Integrity) for security
|
|
61
|
+
- Tree shakes dynamic imports automatically
|
|
62
|
+
- If using custom webpack config, migrate to Turbopack-compatible patterns:
|
|
63
|
+
- Replace `webpack()` in `next.config.js` with Turbopack-native configuration
|
|
64
|
+
- Most loaders have Turbopack equivalents — check the Next.js docs
|
|
65
|
+
- Web Workers: use `new Worker(new URL('./worker.ts', import.meta.url))` for proper bundling
|
|
66
|
+
|
|
67
|
+
## Caching (Next.js 16+)
|
|
68
|
+
- Route stale time is decoupled from segment-level data — configure independently
|
|
69
|
+
- Browser cache no longer serves stale RSC (React Server Component) responses
|
|
70
|
+
- Use `staleTimes` in `next.config.js` for fine-grained stale time control
|
|
71
|
+
- Prefer `fetch()` cache options over route-level `revalidate` for granular control
|
|
72
|
+
|
|
57
73
|
## Common Mistakes to Avoid
|
|
58
74
|
- Don't use `useEffect` for data fetching in Server Components
|
|
59
75
|
- Don't import server-only code in Client Components
|
|
60
76
|
- Don't use `router.push` for simple navigation — use `<Link>`
|
|
61
77
|
- Don't forget to add `loading.tsx` for route transitions
|
|
62
78
|
- Don't throw errors from Server Actions — return error objects instead
|
|
63
|
-
- Don't use Node.js APIs in Middleware — it runs on the Edge runtime
|
|
79
|
+
- Don't use Node.js APIs in Middleware — it runs on the Edge runtime
|
|
80
|
+
- Don't use custom `webpack()` config in Next.js 16+ without checking Turbopack compatibility
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
# Sitecore XM Cloud
|
|
1
|
+
# Sitecore XM Cloud (SitecoreAI)
|
|
2
2
|
|
|
3
3
|
## Architecture
|
|
4
|
-
- This is a headless CMS project using Sitecore XM Cloud with Next.js as the rendering host
|
|
4
|
+
- This is a headless CMS project using Sitecore XM Cloud (part of the SitecoreAI platform) with Next.js as the rendering host
|
|
5
5
|
- Components receive data through Sitecore Layout Service via `ComponentRendering` props
|
|
6
6
|
- Use `@sitecore-jss/sitecore-jss-nextjs` or `@sitecore-content-sdk/nextjs` for component bindings
|
|
7
7
|
|
|
@@ -60,6 +60,14 @@ These standards are enforced across all projects.
|
|
|
60
60
|
- Prefer native browser APIs over utility libraries when reasonable
|
|
61
61
|
- Note the reason for new dependencies in the doc file or PR
|
|
62
62
|
|
|
63
|
+
### Documentation Verification
|
|
64
|
+
- AI training data has a cutoff — verify API signatures before using unfamiliar or recently released APIs
|
|
65
|
+
- Check this project's existing code first for patterns and API usage
|
|
66
|
+
- Use Context7 MCP to fetch current, version-specific docs when available
|
|
67
|
+
- Official llms.txt endpoints: Next.js (`https://nextjs.org/docs/llms-full.txt`)
|
|
68
|
+
- Do NOT guess at API signatures — look them up if unsure
|
|
69
|
+
- The code examples in these rules are current and verified — prefer them over memory
|
|
70
|
+
|
|
63
71
|
### Quality
|
|
64
72
|
- Read existing code before modifying — match patterns, naming, and structure
|
|
65
73
|
- Keep changes minimal and scoped to the request
|
|
@@ -10,4 +10,7 @@
|
|
|
10
10
|
- Streaming: wrap slow components in `<Suspense fallback={...}>` for progressive rendering
|
|
11
11
|
- ISR: use `fetch(url, { next: { revalidate: N } })` or `export const revalidate = N`
|
|
12
12
|
- Middleware: place `middleware.ts` at project root, use `matcher` config, Edge-compatible APIs only
|
|
13
|
-
- Route Groups: use `(groupName)/` for organization without affecting URL paths
|
|
13
|
+
- Route Groups: use `(groupName)/` for organization without affecting URL paths
|
|
14
|
+
- Turbopack (Next.js 16+): use `next dev --turbopack` for ~4x faster dev, Server Fast Refresh for instant HMR
|
|
15
|
+
- Caching (Next.js 16+): route stale time is decoupled from data — use `staleTimes` in `next.config.js` for control
|
|
16
|
+
- Don't use custom `webpack()` in Next.js 16+ without checking Turbopack compatibility
|