Skip to content

Universal SEO skill for Claude Code. 26 sub-skills + 19 sub-agents covering technical SEO, E-E-A-T, schema, GEO/AEO, agent readiness (Lighthouse Agentic Browsing, WebMCP, llms.txt), backlinks, local SEO, e-commerce, international SEO, Google APIs, and PDF/Excel reporting. 9 optional extensions for live SEO data.

feat(seo-cockpit): 0.3.2 a default site that opens from any folder

Agrici Daniel07e015bf938b
diff --git a/plugins/seo-cockpit/.claude-plugin/plugin.json b/plugins/seo-cockpit/.claude-plugin/plugin.json
index 804b8b3..eeafcdd 100644
--- a/plugins/seo-cockpit/.claude-plugin/plugin.json
+++ b/plugins/seo-cockpit/.claude-plugin/plugin.json
@@ -1,6 +1,6 @@
{
"name": "seo-cockpit",
- "version": "0.3.1",
+ "version": "0.3.2",
"description": "Mods companion for claude-seo: a spend guard on paid SEO APIs, a live audit band with a receipt, an economy mode, a visual cockpit (Search Console, rankings, Core Web Vitals, audit, Maps, spend) and zero-token commands",
"author": {
"name": "Agrici Daniel"
@@ -40,14 +40,14 @@
},
"site": {
"type": "string",
- "title": "Search Console property",
- "description": "For the cockpit: sc-domain:example.com or https://example.com/. Leave empty to use claude-seo's default property.",
+ "title": "Default site",
+ "description": "The site the cockpit opens on when the folder shows none: claude-seo.md, sc-domain:claude-seo.md or https://claude-seo.md/. A site chosen in a folder, or that folder's audit, still comes first.",
"default": ""
},
"pageUrl": {
"type": "string",
"title": "Page for Core Web Vitals",
- "description": "For the cockpit's Vitals and drift views: a URL or origin. Leave empty to use the Search Console property's site.",
+ "description": "For the Vitals and drift views of the default site: a URL or origin. Leave empty to use the site's home page.",
"default": ""
},
"googleAccount": {
diff --git a/plugins/seo-cockpit/README.md b/plugins/seo-cockpit/README.md
index d6d7252..4708750 100644
--- a/plugins/seo-cockpit/README.md
+++ b/plugins/seo-cockpit/README.md
@@ -54,7 +54,7 @@ claude-seo.md from this folder
r: Refresh e: Export
```
-- **The site** comes from `/config` if you set one, else from the newest `<domain>-audit/` folder here. With neither, the pane asks for it in place and remembers it for this folder.
+- **The site**, most specific first: one you chose in this folder (typed in the pane, or `/seo-cockpit <site>`), the site of this folder's newest `<domain>-audit/`, your **Default site** from `/config`, then the last site you used. Set a Default site once and the cockpit opens on it from any folder; the Audit row finds that site's audit wherever it was last seen.
- **Google access** uses claude-seo's own setup, or the two Google settings in `/config`. If Search Console says "no access" for a property you own, a service account is being used: set "Google account" to `gcloud` after `gcloud auth application-default login --scopes=https://www.googleapis.com/auth/webmasters.readonly,https://www.googleapis.com/auth/cloud-platform`. Core Web Vitals needs a Google API key ("Google API key" in `/config`).
- **Where it sits:** in a normal terminal the pane opens above the prompt and asks for as many rows as the screen can spare (drag it to resize; your size is kept). In Claude Code's fullscreen layout, 110 columns or wider, it docks beside the conversation at full height.
- **Everything loads on open**, from free sources only (the audit and grid files, the cost ledger, and Search Console and CrUX through claude-seo's own Google setup). The last result shows at once and is replaced when the fresh one arrives.
@@ -92,7 +92,7 @@ Auto-update is off by default for third-party marketplaces. Run `claude plugin u
| Spend guard | on | Turn off to let paid calls through unchecked |
| Audit band | on | The live line above the prompt during an audit |
| Economy mode | off | Run the five Opus agents on Sonnet |
-| Search Console property | empty | For the cockpit: `sc-domain:example.com` or `https://example.com/`. Empty uses claude-seo's default property |
+| Default site | empty | The site the cockpit opens on when a folder shows none (`claude-seo.md`, `sc-domain:claude-seo.md` or `https://claude-seo.md/`). A site chosen in a folder, or its audit, comes first |
| Page for Core Web Vitals | empty | For the Vitals and drift views. Empty uses the property's site |
| Google account | auto | `auto`: claude-seo's own order (its sign-in, a service account, then your gcloud account). `gcloud`: always your own account from `gcloud auth application-default login`, for properties you own |
| Google API key | empty | For Core Web Vitals (CrUX). Sensitive: kept in Claude Code's secure storage. Empty uses claude-seo's own setup |
diff --git a/plugins/seo-cockpit/hooks/lib/overview.ts b/plugins/seo-cockpit/hooks/lib/overview.ts
index c6e695f..e693a8a 100644
--- a/plugins/seo-cockpit/hooks/lib/overview.ts
+++ b/plugins/seo-cockpit/hooks/lib/overview.ts
@@ -45,9 +45,26 @@ export function siteOfAudit(folder: string, data: unknown): string | null {
return fromData ?? hostOf(folder.replace(/-audit$/, ''))
}
-/** The target in order: the person's setting, what they typed in the pane, then what the folder shows. */
-export function chooseTarget(setting: string, typed: string | null, inferred: string | null): string | null {
- return hostOf(setting) ?? (typed === null ? null : hostOf(typed)) ?? inferred
+/**
+ * The target, most specific first: what the person chose for this folder
+ * (typed in the pane, or `/seo-cockpit <site>`), the site this folder's audit
+ * is about, then the default from /config. The caller falls back to the last
+ * site used when all three are empty.
+ */
+export function chooseTarget(setting: string, typed: string | null, inferred: string | null): { host: string | null; source: 'typed' | 'folder' | 'setting' | null } {
+ const chosen = typed === null ? null : hostOf(typed)
+
+ if (chosen !== null) {
+ return { host: chosen, source: 'typed' }
+ }
+
+ if (inferred !== null) {
+ return { host: inferred, source: 'folder' }
+ }
+
+ const fallback = hostOf(setting)
+
+ return fallback === null ? { host: null, source: null } : { host: fallback, source: 'setting' }
}
const kpi = (model: TabModel, label: string): string | undefined => model.kpis.find(k => k.label === label)?.value
diff --git a/plugins/seo-cockpit/hooks/register.ts b/plugins/seo-cockpit/hooks/register.ts
index 8fb1521..efe6f0e 100644
--- a/plugins/seo-cockpit/hooks/register.ts
+++ b/plugins/seo-cockpit/hooks/register.ts
@@ -350,6 +350,37 @@ const isModel = (value: unknown): value is TabModel => {
return typeof m === 'object' && m !== null && typeof m.heading === 'string' && Array.isArray(m.kpis) && Array.isArray(m.charts) && Array.isArray(m.tables) && Array.isArray(m.notes)
}
+/** The audit for a site: a live one, this folder's if it is about that site, else the one remembered for it. */
+async function auditFor($: EngineInterface, ctx: Ctx, host: string | null): Promise<[unknown, string]> {
+ if (ctx.audit?.dir != null && (host === null || ctx.audit.domain === host)) {
+ const path = joinPath(ctx.audit.dir, 'audit-data.json')
+
+ return [await readJson($, path), await shown($, path)]
+ }
+
+ const here = await newestFile($, '-audit', name => name === 'audit-data.json')
+
+ if (here !== null) {
+ const data = await readJson($, here)
+
+ if (host === null || siteOfAudit(here.split(/[/\\]/).at(-2) ?? '', data) === host) {
+ return [data, await shown($, here)]
+ }
+ }
+
+ const remembered = host === null ? undefined : await $.store.get(`audit:${host}`).catch(() => undefined)
+
+ if (typeof remembered === 'string') {
+ const data = await readJson($, remembered)
+
+ if (data !== null) {
+ return [data, remembered]
+ }
+ }
+
+ return [null, '']
+}
+
async function readJson($: EngineInterface, path: string): Promise<unknown> {
try {
return JSON.parse(await $.fs.read(path))
@@ -358,7 +389,7 @@ async function readJson($: EngineInterface, path: string): Promise<unknown> {
}
}
-/** The site the cockpit is about: /config, then what was typed in the pane, then what this folder shows. */
+/** The site the cockpit is about: this folder's choice, its audit, the /config default, then the last site used. */
async function resolveHost($: EngineInterface, ctx: Ctx): Promise<void> {
const cwd = await $.session.cwd().catch(() => '')
@@ -377,12 +408,18 @@ async function resolveHost($: EngineInterface, ctx: Ctx): Promise<void> {
const folder = path.split(/[/\\]/).at(-2) ?? ''
inferred = siteOfAudit(folder, await readJson($, path))
+
+ // Remember where this site's audit lives, so the Audit row works from any folder.
+ if (inferred !== null) {
+ void $.store.set(`audit:${inferred}`, path).catch(() => undefined)
+ }
}
}
- const setting = ctx.pageUrl || ctx.site
- let host = chooseTarget(setting, ctx.typed, inferred)
- let source: PaneState['hostSource'] = host === null ? null : hostOf(setting) !== null ? 'setting' : ctx.typed !== null && hostOf(ctx.typed) !== null ? 'typed' : 'folder'
+ const setting = ctx.site || ctx.pageUrl
+ const chosen = chooseTarget(setting, ctx.typed, inferred)
+ let host = chosen.host
+ let source: PaneState['hostSource'] = chosen.source
// Nothing here says which site: use the last one seen anywhere, and say so.
if (host === null) {
@@ -409,10 +446,10 @@ async function buildTab($: EngineInterface, ctx: Ctx, tab: TabId): Promise<TabMo
}
const host = ctx.pane.host
- // An explicit property wins; otherwise the site's domain property, the usual Search Console setup.
- const property = ctx.site.trim() || (host === null ? '' : `sc-domain:${host}`)
+ // The /config property and page apply only to the site they name; any other site uses its domain property and home page.
+ const property = host === null ? '' : hostOf(ctx.site) === host ? ctx.site.trim() : `sc-domain:${host}`
const propertyArgs = property === '' ? [] : ['--property', property]
- const url = ctx.pageUrl || (host === null ? '' : `https://${host}`)
+ const url = host === null ? '' : hostOf(ctx.pageUrl) === host ? ctx.pageUrl : `https://${host}`
if (tab === 'gsc' || tab === 'rankings') {
// With no site, claude-seo would fall back to its own default property, which may be another site.
@@ -449,9 +486,7 @@ async function buildTab($: EngineInterface, ctx: Ctx, tab: TabId): Promise<TabMo
}
if (tab === 'audit') {
- const path = ctx.audit?.dir != null ? joinPath(ctx.audit.dir, 'audit-data.json') : await newestFile($, '-audit', name => name === 'audit-data.json')
-
- return auditModel(path === null ? null : await readJson($, path), await shown($, path), at)
+ return auditModel(...(await auditFor($, ctx, host)), at)
}
if (tab === 'maps') {
diff --git a/plugins/seo-cockpit/hooks/views/pane.ts b/plugins/seo-cockpit/hooks/views/pane.ts
index baec4d2..b04166b 100644
--- a/plugins/seo-cockpit/hooks/views/pane.ts
+++ b/plugins/seo-cockpit/hooks/views/pane.ts
@@ -129,7 +129,7 @@ function footer(kit: Kit, state: PaneState, isFocused: boolean, actions: PaneAct
/** The Overview: which site, then one line per source; missing data stays visible with its fix. */
export function overviewView(kit: Kit, state: PaneState, columns: number, isFocused: boolean, actions: PaneActions): RenderElement {
const { Box, Text, Button } = kit
- const where = { setting: 'from /config', typed: 'typed here', folder: 'from this folder', last: 'last used', none: '' }[state.hostSource ?? 'none']
+ const where = { setting: 'default', typed: 'chosen here', folder: 'from this folder', last: 'last used', none: '' }[state.hostSource ?? 'none']
const children: RenderElement[] = [
// Row 1 carries no controls: the engine draws its close mark at the right edge.
Text({ children: [Text({ bold: true, children: [cut(state.host ?? 'No site yet', Math.max(10, columns - 24))] }), Text({ dimColor: true, children: [where === '' ? '' : ` ${where}`] })] }),
diff --git a/plugins/seo-cockpit/tests/cockpit.test.ts b/plugins/seo-cockpit/tests/cockpit.test.ts
index 58664b5..53417ab 100644
--- a/plugins/seo-cockpit/tests/cockpit.test.ts
+++ b/plugins/seo-cockpit/tests/cockpit.test.ts
@@ -120,6 +120,39 @@ describe('cockpit', () => {
expect((await $.command.run(command('seo-cockpit', 'not a site'))).text).toContain('is not a site')
})
+ test('the default site opens from any folder, with its remembered audit', { options: { site: 'claude-seo.md' } }, async ($, on) => {
+ worldOf(on)
+ on('session.cwd', () => ({ value: '/anywhere' }))
+ on('store.get', ($, e) => ({ value: e.key === 'audit:claude-seo.md' ? '/work/claude-seo.md-audit/audit-data.json' : undefined }))
+ on('store.set', () => ({ value: undefined }))
+ on('fs.read', ($, e) => (e.path.endsWith('audit-data.json') ? { value: AUDIT } : { deny: 'ENOENT' }))
+ on('ui.status', () => ({ value: undefined }))
+ on('ui.open', () => ({ value: { isPlaced: true } }) as never)
+ on('ui.render', () => ({ type: 'Text', props: {}, children: ['engine'] }) as never)
+ mock.clock(on)
+
+ expect((await $.command.run(command('seo-cockpit'))).text).toBe('Cockpit open for claude-seo.md.')
+
+ const ui = await $.ui.mount({ ...NARROW, surface: 'terminal' })
+
+ expect(await ui.find({ type: 'Text', text: /default/ })).toBeDefined()
+ await ui.press({ key: 'refresh' })
+ expect(await ui.find({ key: 'row-audit' })).toBeDefined()
+ })
+
+ test('a site chosen in a folder beats the default', { options: { site: 'claude-seo.md' } }, async ($, on) => {
+ worldOf(on)
+ on('session.cwd', () => ({ value: '/client' }))
+ on('store.get', ($, e) => ({ value: e.key === 'target:/client' ? 'client.example' : undefined }))
+ on('store.set', () => ({ value: undefined }))
+ on('ui.status', () => ({ value: undefined }))
+ on('ui.open', () => ({ value: { isPlaced: true } }) as never)
+ on('ui.render', () => ({ type: 'Text', props: {}, children: ['engine'] }) as never)
+ mock.clock(on)
+
+ expect((await $.command.run(command('seo-cockpit'))).text).toBe('Cockpit open for client.example.')
+ })
+
test('with no pane on screen, it writes the HTML dashboard instead', async ($, on) => {
worldOf(on)