Skip to content

feat(kun): Anthropic optimization sweep — model routing, caps, hooks, vocabulary#109

Open
abdout wants to merge 7 commits into
mainfrom
feat/anthropic-engine-optimization
Open

feat(kun): Anthropic optimization sweep — model routing, caps, hooks, vocabulary#109
abdout wants to merge 7 commits into
mainfrom
feat/anthropic-engine-optimization

Conversation

@abdout
Copy link
Copy Markdown
Contributor

@abdout abdout commented May 24, 2026

Summary

Six-theme sweep aligning kun with Anthropic's latest shipped surface (Claude Code, Claude API, Agent SDK as of 2026-05-24). Closes the audit gap where kun had zero first-class wrappers for prompt caching, extended thinking, the memory tool, Batch API, sandboxing, routines, autofix-pr, output styles, MCP channels, and a handful of other capabilities.

Outcome targets (track via /costs over the next 2 weeks):

  • 40–70% subagent token-cost drop (Theme 2 — per-agent model routing)
  • 50% Batch API discount captured on Tier-2b sweeps (Theme 4 /batch)
  • ~30% MCP description budget freed (Theme 3c — scoping)
  • Captain mode survives compaction (Theme 5 — PreCompact hook)

Themes (one commit each)

# Theme Commit Files Impact
1 Settings hygiene + missing /ship 962ca32 3 Removed 4 doc bugs; created the long-missing ship.md; cleaner schema
2 Per-agent model routing 10da42b 18 Drops blanket Opus env override; Haiku/Sonnet/Opus per workload
3a Paths-gated sweep frontmatter 1edef1a 13 Each sweep auto-loads only when its paths glob matches
3c MCP scoping per strategic agent b029770 14 Each agent declares only the MCP servers it actually needs
4 New Anthropic-feature commands fb96eba 5 /batch, /cache-audit, /memory-bridge, /sandbox, /autofix-pr
6 Tier-3 vocabulary expansion 7a4919b 1 25+ new keywords routing to wrapped or built-in Anthropic features

Theme 5 (PreCompact + ConfigChange hooks) lives at user level (~/.claude/hooks/) and ~/.claude/settings.json — not under version control in this repo.

The intermediate commit 0529478 (Node 22 LTS → 24 LTS bump) was authored by Abdout in a concurrent session on this same branch; included here because it landed mid-sweep and is unrelated to the optimization themes.

What changed where (representative paths)

  • .claude/settings.json — $schema reference, redundant hooks removed (kept Notification)
  • .claude/commands/ship.md — created (chains build → check → push → PR → deploy → autofix-pr)
  • .claude/commands/{batch,cache-audit,memory-bridge,sandbox,autofix-pr}.md — new
  • .claude/commands/{prisma,nextjs,react,tailwind,...}.md — frontmatter (name, description, model, paths, argument-hint)
  • .claude/agents/*.md — model + effort + memory + mcpServers per per-agent policy
  • .claude/CLAUDE.md — Tier 2 split into commands vs skills; Tier 3 adds Anthropic-native vocabulary

Test plan

  • Sanity: `claude --strict-config .claude/settings.json` validates schema
  • /ship dry-run on a throwaway branch — chain completes
  • /captain run shows /costs reporting per-model spend after 1 week
  • /batch translate on a small repo confirms Batch API job creation
  • /cache-audit on a known API-call site emits non-empty report
  • Skill listing shows new descriptions for sweeps + new commands

Notes for reviewers

  • Plan file with full rationale: `~/.claude/plans/read-the-latest-offical-functional-raccoon.md` (local only)
  • Audit covered docs.claude.com 2026-05-24 snapshot; cite-trail in commit bodies
  • Captain agent kept its bespoke 8-server MCP allowlist — Theme 3c only adds where missing
  • mcp-business/content/ops.json still present but no loader; can be wired in a follow-up
  • /feature pipeline kept linear per scope decision; agent-team conversion deferred

🤖 Generated with Claude Code

abdout and others added 7 commits May 24, 2026 12:59
Settings hygiene aligned with current Claude Code schema. Drops project
hooks that duplicate user-level hooks (with worse prettier implementation
that lacked project-root + config presence checks). Adds project $schema
reference and Notification-only hook block (the kun-specific Captain
notification).

CLAUDE.md Tier 2 list now splits project commands from user skills so the
source of each /name is unambiguous; new "skills shadow commands" note
explains the precedence rule.

Creates the long-missing ship.md (referenced in Tier 1 pipeline but never
existed). Stub chains build → check → push → PR → Vercel deploy →
autofix-pr (Theme 4 will add the autofix-pr command).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Replaces the user-level CLAUDE_CODE_SUBAGENT_MODEL=claude-opus-4-7 env
override (every subagent paid Opus prices regardless of work). New policy:

  - Haiku 4.5: mechanical agents (none at project scope — git/github/etc.
    are user-level and updated separately)
  - Sonnet 4.6: product coding agents (report, support, package, hogwarts,
    mkan, shifa, souq) — most volume, doesn't need Opus reasoning
  - Opus 4.7 + effort: xhigh + memory: user: strategic agents (captain,
    tech-lead, learn, analyze, growth, revenue, product, quality-engineer,
    guardian, analyst, ops) — depth + cross-session continuity

Captain keeps its bespoke memory: [...file list...] (already in place);
just adds effort: xhigh. Expected subagent cost drop 40-70%; tracked via
/costs after this lands.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Adds YAML frontmatter to all 13 Tier-2b sweep commands with three fields
the kun engine never used:

  - description: now appears in skill listings (was just markdown heading)
  - model: explicit Sonnet/Haiku per workload (cheap sweeps on Haiku)
  - paths: glob patterns so each sweep auto-loads only when relevant
    files are in context (e.g., prisma activates on schema.prisma + db/**;
    react on *.tsx; tailwind on *.css + tailwind.config.*)

Paths gating reduces skill-listing context budget without changing
behavior when invoked explicitly via /<name>. argument-hint clarifies
each command's accepted args.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Each agent declares only the MCP servers it actually needs, instead of
inheriting the full 25-server project + 19-server user list every prompt.
Frees roughly 30-40% of MCP description budget at the parent context.

  - revenue: stripe, notion, linear, github
  - analyst: posthog, linear, notion, ref
  - growth: notion, posthog, slack, linear, ref
  - product: linear, notion, github, posthog
  - learn: github, notion, linear, slack, memory-bank, filesystem, git
  - report: github, linear, sentry
  - analyze: github, git, filesystem
  - support: linear, notion, slack, github
  - ops: vercel, sentry, posthog, neon, stripe, gcloud
  - tech-lead: github, neon, vercel, ref, context7
  - quality-engineer: linear, sentry, github, a11y
  - guardian: sentry, github, neon
  - hogwarts: neon, stripe, github, postgres
  - package: github, git

Captain keeps its bespoke 8-server allowlist (already in place).
Product agents mkan/shifa/souq scoped to product DB + github only.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Five new commands close the largest documented capability gap. Each is a
small wrapper that delegates to a feature Anthropic already ships but kun
had no command for.

  - /batch — Batch API at 50% discount; Tier-2b sweeps queue overnight,
    finish in <1h, cost half as much
  - /cache-audit — scan API call sites, score caching opportunities,
    suggest cache_control breakpoint placement
  - /memory-bridge — pair memory tool (memory_20250818) with kun's
    ~/.claude/memory/; unifies storage for Claude Code, API, Managed Agents
  - /sandbox — four named presets (captain/dev/strict/off) for Bash
    sandbox so /captain autonomous loops have a real safety net
  - /autofix-pr — hand a PR to a web session that babysits CI; chained
    from /ship by default

Skipped commands for built-in features kun shouldn't redundantly wrap:
/schedule, /loop, /code-review, /verify, /claude-api, /run, /ultraplan,
/ultrareview, /insights, /team-onboarding all already exist as built-in
skills. These are now Tier-3 vocabulary in Theme 6 instead.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Node 24.16.0 Krypton is the current Active LTS as of 2026-05-24; v22 Jod
moved to Maintenance. Updates onboarding.mdx (3 sites), all 3 OS install
scripts, wizard-steps.json, self-hosting.mdx NodeSource pin, and mcp.mdx
Playwright support line.

Mac now pins node@24 (was unpinned brew install node); Windows pins
OpenJS.NodeJS.LTS (was unpinned OpenJS.NodeJS); Linux stays on
nvm install --lts (auto-resolves to current LTS).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Extends Tier 3 vocabulary with four new categories spanning every
Anthropic capability that kun now exposes:

  - Cost/perf: cache, batch, think, fork, compact, route
  - Tools: memory, web-search, web-fetch, code-exec, bash-tool,
    text-editor, files
  - Workflow: goal, routine, schedule, sandbox, team, teleport,
    ultraplan, ultrareview, autofix-pr, channel
  - Insight: insights, team-onboarding, agent-view, verify

Each keyword maps to either a Theme-4 kun wrapper (/batch, /cache-audit,
/memory-bridge, /sandbox, /autofix-pr) or a built-in Claude Code skill
(/schedule, /goal, /insights, /verify, /loop, /code-review). Closes the
documented gap of "user says X, kun has no route".

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented May 24, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
kun Ready Ready Preview, Comment May 24, 2026 11:30am

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant