diff --git a/plugins/aidd-context/skills/12-cook/actions/02-upsert.md b/plugins/aidd-context/skills/12-cook/actions/02-upsert.md index 8dbe2176d..197a7ace7 100644 --- a/plugins/aidd-context/skills/12-cook/actions/02-upsert.md +++ b/plugins/aidd-context/skills/12-cook/actions/02-upsert.md @@ -30,6 +30,6 @@ The recipe file at `aidd_docs/recipes/.md`, filled from the template. ## Test - A new or substantially-updated recipe is drafted from `research` results, not from memory. -- `aidd_docs/recipes/.md` exists and follows the recipe contract: opens with a one-sentence description (no Goal label, no table), each step a `#### N)` emoji heading with a real example, no `<...>` placeholder left. +- `aidd_docs/recipes/.md` exists and follows the recipe contract: opens with a one-sentence description (no Goal label, no table), uses `### N)` for direct steps or `#### N)` below a `###` category without skipping heading levels, gives every step a real example, and leaves no `<...>` placeholder. - A bundled recipe is never overwritten unless the user explicitly asks to change a bundled/framework recipe. - A new recipe that highly overlaps an existing project or bundled recipe triggers an update-or-create prompt before scaffolding. diff --git a/plugins/aidd-context/skills/12-cook/assets/recipe-template.md b/plugins/aidd-context/skills/12-cook/assets/recipe-template.md index 95a189c41..df55f63e3 100644 --- a/plugins/aidd-context/skills/12-cook/assets/recipe-template.md +++ b/plugins/aidd-context/skills/12-cook/assets/recipe-template.md @@ -1,50 +1,37 @@ -# +# Recipe title +- [Recipe title](#recipe-title) + - [Why](#why) + - [Steps to ](#steps-to-) + - [1) First step title](#1--first-step-title) + - [Verify ](#verify-) + ## Why ## Steps to -### ๐ŸŸข Beginner + -#### 1) +### 1) First step title 1. 2. -```bash -$ - -``` - -### ๐ŸŸก Intermediate - -#### 2) - - - -1. -2. - ``` ``` -### ๐Ÿ”ด Expert - -#### 3) - - - -1. - -![]() - -## Verify +## Verify - diff --git a/plugins/aidd-context/skills/12-cook/assets/recipes/install-aiddy-in-codex.md b/plugins/aidd-context/skills/12-cook/assets/recipes/install-aiddy-in-codex.md index 0c92c2cfb..83b8638bd 100644 --- a/plugins/aidd-context/skills/12-cook/assets/recipes/install-aiddy-in-codex.md +++ b/plugins/aidd-context/skills/12-cook/assets/recipes/install-aiddy-in-codex.md @@ -1,27 +1,35 @@ # Install AIDDy in Codex -Install AIDDy, the Agent Y mascot, as a local Codex pet. +Install AIDDy, the Agent Y mascot, as a local custom pet in the ChatGPT desktop app. + +- [Install AIDDy in Codex](#install-aiddy-in-codex) + - [Why](#why) + - [Steps to install and wake AIDDy](#steps-to-install-and-wake-aiddy) + - [1) ๐Ÿ”— Open the AIDDy installer](#1--open-the-aiddy-installer) + - [2) ๐Ÿ“ฆ Confirm the installation](#2--confirm-the-installation) + - [3) ๐Ÿพ Select AIDDy](#3--select-aiddy) + - [4) โ–ถ๏ธ Wake AIDDy](#4-๏ธ-wake-aiddy) + - [Verify](#verify) ## Why -**AIDDy** reflects Codex task activity with the AI-Driven Development mascot. +**AIDDy** reflects ChatGPT task activity with the AI-Driven Development mascot. **Sprite version 2** ensures Codex reads the extended 11-row animation atlas correctly. ## Steps to install and wake AIDDy -#### 1) ๐Ÿ”— Open the AIDDy installer +### 1) ๐Ÿ”— Open the AIDDy installer -The versioned deep link opens the Codex pet installer with the canonical AIDDy atlas. +The immutable deep link opens the pet installer with the canonical AIDDy atlas. -1. Use a machine with the Codex desktop app and internet access. -2. Click [Install AIDDy](codex://pets/install?name=AIDDy&imageUrl=https%3A%2F%2Fraw.githubusercontent.com%2Fai-driven-dev%2Fframework%2Fmain%2Fassets%2Fpets%2Faiddy-spritesheet.webp&description=Agent%20Y%20for%20AI-Driven%20Development&spriteVersionNumber=2). +1. In the ChatGPT desktop app, click [Install AIDDy](codex://pets/install?name=AIDDy&imageUrl=https%3A%2F%2Fraw.githubusercontent.com%2Fai-driven-dev%2Fframework%2F1a52770253628062e4e8cbcda1bd062452354c27%2Fassets%2Fpets%2Faiddy-spritesheet.webp&description=Agent%20Y%20for%20AI-Driven%20Development&spriteVersionNumber=2). ```text -codex://pets/install?name=AIDDy&imageUrl=https%3A%2F%2Fraw.githubusercontent.com%2Fai-driven-dev%2Fframework%2Fmain%2Fassets%2Fpets%2Faiddy-spritesheet.webp&description=Agent%20Y%20for%20AI-Driven%20Development&spriteVersionNumber=2 +codex://pets/install?name=AIDDy&imageUrl=https%3A%2F%2Fraw.githubusercontent.com%2Fai-driven-dev%2Fframework%2F1a52770253628062e4e8cbcda1bd062452354c27%2Fassets%2Fpets%2Faiddy-spritesheet.webp&description=Agent%20Y%20for%20AI-Driven%20Development&spriteVersionNumber=2 ``` -#### 2) ๐Ÿ“ฆ Confirm the installation +### 2) ๐Ÿ“ฆ Confirm the installation The confirmation screen lets you verify the pet before writing it to local Codex storage. @@ -34,14 +42,21 @@ Description: Agent Y for AI-Driven Development Sprite version: 2 ``` -#### 3) ๐Ÿพ Wake AIDDy +### 3) ๐Ÿพ Select AIDDy + +Selecting the installed custom pet makes it active in the ChatGPT desktop app. + +1. Open **Settings > Pets**, select **Refresh** if needed, then choose **AIDDy**. + +```text +Settings > Pets > AIDDy +``` + +### 4) โ–ถ๏ธ Wake AIDDy -Selecting the custom pet makes it available as the animated task companion documented in [Codex pets](https://learn.chatgpt.com/docs/pets). +The `/pet` command wakes the selected companion so it can report task activity. -1. Open **Settings > Pets**. -2. Refresh custom pets if AIDDy is not visible yet. -3. Select **AIDDy**. -4. Enter `/pet` in a task. +1. Enter `/pet` in a task. ```text /pet @@ -51,4 +66,5 @@ Selecting the custom pet makes it available as the animated task companion docum - AIDDy appears in **Settings > Pets** as a custom pet. - `/pet` shows AIDDy and its animation changes with task activity. -- The link uses only the supported [pet install parameters](https://learn.chatgpt.com/docs/reference/app-commands#pets), including `spriteVersionNumber=2`. +- The link uses only the supported [pet install parameters](https://learn.chatgpt.com/docs/reference/commands#pets), including `spriteVersionNumber=2`. +- The pinned atlas has SHA-256 `a97872f637a6711da4a88cbbb56f9038b2fcb4ce870e021c9d2355a3421ad5a4`. diff --git a/plugins/aidd-context/skills/12-cook/assets/recipes/mcp-installation.md b/plugins/aidd-context/skills/12-cook/assets/recipes/mcp-installation.md index 698280dd3..752322dde 100644 --- a/plugins/aidd-context/skills/12-cook/assets/recipes/mcp-installation.md +++ b/plugins/aidd-context/skills/12-cook/assets/recipes/mcp-installation.md @@ -1,60 +1,155 @@ # MCP installations -Decide when to use an MCP server vs a CLI, and wire up the recommended ones. +Choose between a CLI and MCP by capability, then install the integration through the configuration native to your AI client. + +- [MCP installations](#mcp-installations) + - [Why](#why) + - [Steps to install the right integration](#steps-to-install-the-right-integration) + - [1) ๐Ÿ”Ž Choose by capability](#1--choose-by-capability) + - [2) โŒจ๏ธ Install the CLI route](#2-๏ธ-install-the-cli-route) + - [3) ๐Ÿ”Œ Install the MCP route](#3--install-the-mcp-route) + - [4) ๐Ÿ” Restrict access](#4--restrict-access) + - [5) โœ… Verify the connection](#5--verify-the-connection) + - [6) ๐Ÿงน Remove or revoke access](#6--remove-or-revoke-access) + - [Verify](#verify) ## Why -**MCP servers** load their full tool schema into every turn, which bloats the context window. +**Capability fit** matters more than whether a CLI happens to exist. -**CLI calls** cost a few tokens and return only what you ask for. +**[Claude Code Tool Search](https://code.claude.com/docs/en/mcp#scale-with-mcp-tool-search)** defers full MCP tool schemas on supported models and providers; other clients and MCP capabilities may load differently. -**Reach for MCP only when no CLI covers the service.** +**Native configuration** uses the file, schema, scope, and installation flow documented by the selected client. -**Audit what you install** before connecting any server. +**Least privilege** limits the impact of write tools, broad OAuth access, and prompt injection. -## Steps to choose and install the right integration +## Steps to install the right integration -#### 1) ๐Ÿ”Ž Check for a CLI first +### 1) ๐Ÿ”Ž Choose by capability -The CLI is usually cheaper because it does not inject a large tool schema into every turn. +Choose the smallest interface that fully covers the workflow, authentication model, and data scope. -1. Look for an official CLI before adding an MCP server. -2. Install and authenticate the CLI when it covers the workflow. -3. Keep MCP for services with no useful CLI alternative. +1. Compare the exact operation you need against the table. -| Service | Official MCP | CLI alternative | Recommended | +| Need | Prefer a CLI | Prefer MCP | +| --- | --- | --- | +| Scriptable commands and raw API calls | The official CLI covers the operation and its output is manageable | The client needs typed discovery or structured results | +| Live design or knowledge context | The CLI exposes the required operation and data | The server advertises the required tools, resources, or prompts | +| Authentication | The CLI's login and credential storage fit the workflow | The server's authentication, requested scopes, and host credential storage fit the workflow | +| Context cost | Output is requested only when the command runs | The client supports deferred loading such as [Claude Code Tool Search](https://code.claude.com/docs/en/mcp#scale-with-mcp-tool-search) | + +The last column is a decision heuristic for this recipe, not a provider guarantee. + +| Service | CLI route | MCP route | Recipe heuristic | | --- | --- | --- | --- | -| **GitHub** | [`api.githubcopilot.com/mcp/`](https://github.com/github/github-mcp-server) | [`gh`](https://cli.github.com/) | **CLI**: issues, PRs, releases, and API calls without the MCP schema cost | -| **Atlassian** (Jira / Confluence) | [`mcp.atlassian.com/v1/mcp`](https://www.atlassian.com/platform/remote-mcp-server) | [`acli`](https://developer.atlassian.com/cloud/acli/guides/introduction/) for Jira | **CLI** for Jira, **MCP** for Confluence | -| **Playwright** | [`@playwright/mcp`](https://github.com/microsoft/playwright-mcp) | [`npx playwright`](https://playwright.dev/docs/test-cli) | **CLI**: a real browser through `playwright open`, `codegen`, or `--headed` | -| **Figma** | [`mcp.figma.com/mcp`](https://developers.figma.com/docs/figma-mcp-server/remote-server-installation/) | none for design data | **MCP** | -| **Notion** | [`mcp.notion.com/mcp`](https://developers.notion.com/guides/mcp/get-started-with-mcp) | none official | **MCP** | +| [GitHub](https://github.com/github/github-mcp-server) | [`gh`](https://cli.github.com/) | Remote toolsets, including read-only modes | CLI for routine API work; MCP for typed or remote-only capabilities | +| [Atlassian](https://www.atlassian.com/platform/rovo-mcp) | [`acli`](https://developer.atlassian.com/cloud/acli/guides/introduction/) for Jira | The current Rovo MCP tool catalog; [OAuth 2.1 is recommended](https://support.atlassian.com/atlassian-rovo-mcp-server/docs/configuring-oauth-2-1/), with API-token authentication only when an administrator enables it | Decide from the Atlassian product, operation, and permitted authentication | +| [Playwright](https://github.com/microsoft/playwright-mcp) | [`@playwright/cli`](https://playwright.dev/agent-cli/installation) | `@playwright/mcp` | CLI for direct browser automation; MCP for live tool calls | +| [Figma](https://developers.figma.com/docs/figma-mcp-server/remote-server-installation/) | The [`@figma/code-connect` CLI](https://developers.figma.com/docs/code-connect/cli-reference/) manages component mappings, not live design context or canvas operations | `https://mcp.figma.com/mcp` | CLI for Code Connect mappings; MCP for live design and canvas workflows | +| [Notion](https://developers.notion.com/guides/mcp/get-started-with-mcp) | The official [`ntn` CLI](https://developers.notion.com/cli/get-started/overview) supports API, page, data-source, file, and Worker operations | `https://mcp.notion.com/mcp` | CLI for scripts and raw API work; MCP for agent workflows, with human confirmation | + +### 2) โŒจ๏ธ Install the CLI route + +The agent-oriented Playwright CLI is a direct browser alternative to Playwright MCP. + +1. Install `@playwright/cli` from the [official guide](https://playwright.dev/agent-cli/installation), then invoke its `playwright-cli` executable. + +```bash +npm install -g @playwright/cli@latest +playwright-cli open https://example.com --headed +``` + +Use `npx playwright test` for the test runner and `npx playwright codegen` for test generation; they are different command surfaces. + +### 3) ๐Ÿ”Œ Install the MCP route + +Use a provider-supported client and distinguish the recommended plugin route from manual MCP configuration. + +1. Pick the [documented Figma route](https://developers.figma.com/docs/figma-mcp-server/remote-server-installation/) for your client. + +| Client | Figma's recommended route | Manual alternative and scope | +| --- | --- | --- | +| Claude Code | `claude plugin install figma@claude-plugins-official` | `claude mcp add --transport http --scope project figma https://mcp.figma.com/mcp` writes project configuration to `.mcp.json` under `mcpServers` | +| Codex | In the Codex app, open **Plugins**, select **+** next to Figma, then **Install Figma** | `codex mcp add figma --url https://mcp.figma.com/mcp` writes to [`~/.codex/config.toml`](https://learn.chatgpt.com/docs/extend/mcp?surface=cli) under `mcp_servers`; trusted projects may instead use `.codex/config.toml` | +| Cursor | Run `/add-plugin figma` | Manual project configuration uses `.cursor/mcp.json` under `mcpServers` | +| GitHub Copilot in VS Code | Run **MCP: Open Workspace Folder MCP Configuration**, paste Figma's documented server object, then select **Start** | Workspace configuration uses `.vscode/mcp.json` under `servers` | + +```bash +claude plugin install figma@claude-plugins-official +``` -#### 2) ๐Ÿ”Œ Add MCP only when it is the right integration +[Figma accepts only clients in its MCP catalog](https://www.figma.com/mcp-catalog/); do not extrapolate these instructions to an unlisted host. -An MCP config belongs in the assistant's MCP configuration file, and only for services where MCP is the best available interface. +### 4) ๐Ÿ” Restrict access -1. Read the provider docs and permission model. -2. Add the server to `.mcp.json`. -3. Restart the assistant so it picks up the new tools. +Use the server's documented authentication, expose only required capabilities, and enforce confirmation for mutations. + +1. If the remote server uses OAuth, authorize it in the client and review the requested scopes; otherwise follow its documented authentication method. +2. Prefer read-only endpoints, toolsets, or allowlists when the workflow only reads. +3. Configure the host to require confirmation for mutating tools; if it cannot, disable write tools or use a provider-enforced read-only mode. + +[GitHub documents](https://github.com/github/github-mcp-server/blob/main/docs/server-configuration.md#read-only-mode) this VS Code-format server-entry fragment; place it under `servers.github` in `.vscode/mcp.json`, or adapt the wrapper to the selected host: ```json { - "mcpServers": { - "figma": { "url": "https://mcp.figma.com/mcp" } + "type": "http", + "url": "https://api.githubcopilot.com/mcp/", + "headers": { + "X-MCP-Toolsets": "repos,issues", + "X-MCP-Readonly": "true" } } ``` -#### 3) โœ… Verify the integration +[Notion MCP inherits the connected user's workspace access](https://developers.notion.com/guides/mcp/mcp-security-best-practices), so review every write and any data sent to another tool. + +### 5) โœ… Verify the connection + +Verify the configured server, authenticated identity, exposed tools, and one read-only operation before relying on it. + +1. Inspect the server through the client, then run a harmless read. + +```text +Claude Code: /mcp +Codex: codex mcp list +Cursor: Settings > Cursor Settings > Tools & MCP +VS Code: MCP: List Servers +``` + +Figma's documented successful Claude Code flow ends with: -Verification keeps a bad install out of later sessions. +```text +Authentication successful. Connected to figma +``` + +Use Figma's read-only [`whoami`](https://developers.figma.com/docs/figma-mcp-server/tools-and-prompts/#whoami-remote-only) tool to confirm the authenticated email, plans, and seat type. + +### 6) ๐Ÿงน Remove or revoke access + +Clear stored authentication, remove local configuration, then revoke the provider grant when one exists. -1. For MCP, confirm the tools appear in the assistant. -2. For a CLI, run a read-only identity command. +1. Clear authentication before removing the server entry. +2. Remove the server or plugin from the client. +3. For Figma, open [**Settings > Security > Connected apps**](https://help.figma.com/hc/en-us/articles/15021280611607-How-do-I-keep-my-account-secure) and select **Revoke access**. + +| Client | Clear authentication | Remove local configuration | +| --- | --- | --- | +| Claude Code | Run `/mcp`, select Figma, then **Clear authentication** | Plugin: `claude plugin uninstall figma@claude-plugins-official`; manual project server: `claude mcp remove --scope project figma` | +| Codex | Manual server: `codex mcp logout figma` | Plugin: remove Figma in the Codex app's **Plugins** panel; manual server: `codex mcp remove figma` | +| Cursor | Disconnect Figma under **Settings > Cursor Settings > Tools & MCP** | Remove the Figma plugin or its manual `.cursor/mcp.json` entry | +| GitHub Copilot in VS Code | Select the server through **MCP: List Servers** | Uninstall the server or remove its `.vscode/mcp.json` entry | ```bash -$ gh auth status -github.com - โœ“ Logged in to github.com account octocat +codex mcp logout figma +codex mcp remove figma ``` + +Removing configuration alone does not prove that the OAuth grant was revoked. + +## Verify + +- The server appears in the chosen client's server list with the expected transport and scope. +- Authentication uses the intended account and workspace. +- Only the required tools are enabled; mutating calls require confirmation or are disabled. +- Figma `whoami` returns the intended identity. +- Authentication clearing, local removal, and provider revocation are separate and documented. diff --git a/plugins/aidd-context/skills/12-cook/assets/recipes/token-optimization.md b/plugins/aidd-context/skills/12-cook/assets/recipes/token-optimization.md index 67c096fa9..4709ed1be 100644 --- a/plugins/aidd-context/skills/12-cook/assets/recipes/token-optimization.md +++ b/plugins/aidd-context/skills/12-cook/assets/recipes/token-optimization.md @@ -1,277 +1,339 @@ -# Token optimization for AI IDEs +# Token optimization across coding agents + +Cut token usage across coding agents without confusing general techniques with Claude Code or Codex commands. + +- [Token optimization across coding agents](#token-optimization-across-coding-agents) + - [Why](#why) + - [Steps to cut token usage](#steps-to-cut-token-usage) + - [๐ŸŸข Beginner](#-beginner) + - [1) ๐Ÿ“ Record a before-and-after baseline](#1--record-a-before-and-after-baseline) + - [2) ๐Ÿ”Ž Inspect Claude's context breakdown](#2--inspect-claudes-context-breakdown) + - [3) โœ‚๏ธ Trim persistent instructions](#3-๏ธ-trim-persistent-instructions) + - [4) ๐Ÿงญ Plan before expensive rework](#4--plan-before-expensive-rework) + - [5) โ™ป๏ธ Reset between unrelated tasks](#5-๏ธ-reset-between-unrelated-tasks) + - [6) ๐Ÿ—œ๏ธ Compact at a natural boundary](#6-๏ธ-compact-at-a-natural-boundary) + - [๐ŸŸก Intermediate](#-intermediate) + - [7) ๐Ÿ“ˆ Export structured usage telemetry](#7--export-structured-usage-telemetry) + - [8) ๐Ÿ—ฃ๏ธ Make concise output explicit](#8-๏ธ-make-concise-output-explicit) + - [9) ๐Ÿงน Filter noisy shell output selectively](#9--filter-noisy-shell-output-selectively) + - [10) ๐Ÿ”Œ Limit MCP exposure by client](#10--limit-mcp-exposure-by-client) + - [๐Ÿ”ด Expert](#-expert) + - [11) ๐Ÿ”ฌ Inspect client behavior without mixing shortcuts](#11--inspect-client-behavior-without-mixing-shortcuts) + - [12) ๐ŸŽฏ Route model and reasoning by difficulty](#12--route-model-and-reasoning-by-difficulty) + - [13) ๐Ÿงซ Isolate noisy work with subagents](#13--isolate-noisy-work-with-subagents) + - [14) ๐ŸงŠ Protect Claude Code prompt-cache stability](#14--protect-claude-code-prompt-cache-stability) + - [In short](#in-short) + +## Why + +**Token usage** grows with persistent instructions, conversation history, tool output, and reasoning. + +**Command names are not portable contracts**: `/usage`, `/compact`, `/model`, and keyboard shortcuts can differ across clients. + +**Applicability labels** separate portable techniques from verified Claude Code and Codex mechanics. No command is labeled as universal. -Cut token usage and cost in AI coding assistants without losing output quality. +## Steps to cut token usage -## Why optimize your tokens +### ๐ŸŸข Beginner -**Token usage** is the bill โ€” every turn re-sends your whole **context window** and you pay for it again. +#### 1) ๐Ÿ“ Record a before-and-after baseline -Most of it is **waste**: filler prose, noisy logs, stale context, bloated instruction files. +**Applies to:** Claude Code and Codex; their counters differ. -Reach for this recipe when **cost** climbs faster than your output. +1. Run the same task with the same model and reasoning level before and after one optimization, then record the command result and quality gate. -## Steps to cut token usage +| Client | Command | Record | +| --- | --- | --- | +| Claude Code | `/usage` | Session usage and available breakdowns | +| Codex | `/status` | Context usage under the current chat configuration | -### ๐ŸŸข Beginner +Compare only within the same client. See [Claude Code costs](https://code.claude.com/docs/en/costs) and [Codex commands](https://learn.chatgpt.com/docs/developer-commands?surface=cli). -#### 1) ๐Ÿ”Ž See what fills the window โ€” `/context` +#### 2) ๐Ÿ”Ž Inspect Claude's context breakdown -`/context` paints your context as a grid, so you cut the biggest consumers instead of guessing. +**Applies to:** Claude Code. Codex has no equivalent component grid. -1. Run `/context` in Claude Code. -2. Find the heavy blocks: tool schemas, instruction files, long file reads. -3. Attack the biggest block first. +1. Run `/context all` only when the baseline shows context pressure. ```text -$ /context - MCP tool schemas โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ 28% โ† biggest, cut first - file reads โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ 19% - CLAUDE.md โ–ˆโ–ˆโ–ˆโ–ˆ 9% -(illustrative โ€” replace with a screenshot of your real /context) +/context all ``` -#### 2) ๐Ÿ’ธ Read the bill โ€” `/cost` +Target the largest persistent instruction, tool, or history source before compacting. -`/cost` tells you what a session actually costs and where the spend goes. +#### 3) โœ‚๏ธ Trim persistent instructions -1. Run `/cost` (alias `/usage`). -2. Read the breakdown by skill, subagent, and MCP server. -3. Re-run it after a change to confirm the spend really dropped. +**Applies to:** All coding agents; the instruction file is client-specific. -```text -$ /cost - Session: $0.42 ยท 1.2M tokens - By: subagents 38% ยท MCP 21% ยท main 41% -(illustrative โ€” replace with a screenshot of your real /cost) -``` +Keep only durable rules in the file that loads for every task, and move specialized procedures to on-demand skills or referenced documents. -#### 3) ๐Ÿ” Find your bad habits โ€” `/insights` +1. Open only the persistent instruction file documented by your client. +2. Remove duplicated architecture prose, one-off task details, and commands the agent can discover safely. +3. Keep completion criteria, constraints, and the canonical validation commands. -`/insights` analyses how you prompt โ€” probably sub-optimal โ€” so you fix the pattern, not one prompt. What you repeat every session belongs in the knowledge base, and the counter-intuitive habits you never noticed get surfaced so you can drop them. +| Client | Native persistent instructions | +| --- | --- | +| Claude Code | `CLAUDE.md` | +| Codex | `AGENTS.md` or the closer `AGENTS.override.md` | +| Other clients | Use only the filename and precedence documented by that client | -1. Run `/insights`. -2. Move what you repeat into `CLAUDE.md` or a rule, and drop the habits it flags. +```md +# Persistent instructions -```text -$ /insights - โ€ข You restate the test command in ~60% of sessions โ†’ put it in CLAUDE.md - โ€ข Long "summary" turns inflate output โ†’ ask for terse replies -(illustrative โ€” replace with a screenshot of your real /insights) +- Lead with the result. +- Run the smallest relevant validation. +- Preserve unrelated user changes. ``` -#### 4) ๐Ÿ“ˆ Track per-prompt with an analytics tool - -Built-ins show one session; an analytics tool reads all your local logs and reveals where the bill truly sits. The lesson it surfaces: **cache reads dwarf input + output**, so caching, not generation, is most of the bill. +See [Claude Code memory](https://code.claude.com/docs/en/memory) and [Codex AGENTS.md](https://learn.chatgpt.com/docs/agent-configuration/agents-md). -1. Pick one: [`prompt-analytics-for-claude-code`](https://github.com/romainfjgaspard/prompt-analytics-for-claude-code) or [`ccusage`](https://www.npmjs.com/package/ccusage). -2. Run it โ€” `uvx --from prompt-analytics-for-claude-code prompt-analytics summary` โ€” no setup, it parses `~/.claude`. +#### 4) ๐Ÿงญ Plan before expensive rework -![prompt-analytics dashboard โ€” cost by token type shows cache reads dominate the bill](https://raw.githubusercontent.com/romainfjgaspard/prompt-analytics-for-claude-code/main/docs/screenshots/dashboard-home.png) +**Applies to:** All coding agents as a technique; commands are client-specific. -#### 5) โœ‚๏ธ Trim your instruction file +Plan first when ambiguity or implementation risk makes a wrong direction expensive. -Your instruction file ships every turn, so each cut line saves on every message. +1. Enter the documented plan surface for your client. +2. Review scope, assumptions, and validation before authorizing implementation. +3. Use a separate read-only permission or sandbox setting when planning must prohibit writes; plan mode alone is not a universal security boundary. -1. Open `CLAUDE.md` (or `.github/copilot-instructions.md`). -2. Cut it to essentials and add explicit conciseness rules. -3. Model it on a real concise instruction file: [AGENTS.md](../../../02-project-memory/assets/AGENTS.md). +| Client | Plan command | +| --- | --- | +| Claude Code | `/plan` or launch with `claude --permission-mode plan` | +| Codex | `/plan`; the command can include the first planning prompt | +| Other clients | Ask for a plan explicitly; use only a documented plan mode if one exists | -```md -# CLAUDE.md โ€” keep it terse (see AGENTS.md for the full example) -- Answer first. Lead with the result, then the reason. Drop pleasantries and hedging. -- No tool-call narration. No decorative tables or emoji unless they carry information. -- Keep verbatim: code, quoted errors, security warnings. Cut the rest. +```text +/plan Propose the smallest implementation and its validation before editing ``` -#### 6) ๐Ÿงญ Plan before you edit โ€” plan mode +See [Claude Code permission modes](https://code.claude.com/docs/en/permission-modes) and [Codex best practices](https://learn.chatgpt.com/guides/best-practices). -Approving the wrong direction burns tokens on rework, so let Claude explore read-only and propose a plan first. +#### 5) โ™ป๏ธ Reset between unrelated tasks -1. Press `Shift+Tab` twice to enter plan mode (or start with `claude --permission-mode plan`). -2. Review the plan, then approve to switch to execution. +**Applies to:** All coding agents as a technique; slash commands are verified only for the named clients. -```text -Shift+Tab Shift+Tab โ†’ โธ plan mode - Claude reads and proposes; no edits until you approve -``` - -See [permission modes](https://code.claude.com/docs/en/permission-modes). - -#### 7) โ™ป๏ธ Clear context between tasks โ€” `/clear` +Start a fresh conversation when the goal changes instead of paying repeatedly for stale turns. -Stale early turns ride along and get re-billed every turn, so reset when the task changes. +1. Preserve any durable decision outside the disposable transcript. +2. Reset with the client-native action. -1. Finish a task, then run `/clear` to drop the history and reload only `CLAUDE.md` and memory. -2. Use `/compact` instead when you want to keep a summary of the same task. +| Client | Fresh-context action | +| --- | --- | +| Claude Code | `/clear` | +| Codex CLI | `/clear` clears the terminal and starts a fresh chat; `/new` starts another chat without clearing the display | +| Other clients | Start a new conversation through the documented UI | ```text -$ /clear - history dropped โ†’ fresh window, CLAUDE.md + memory reloaded +Claude Code: /clear +Codex: /new ``` -See [reduce token usage](https://code.claude.com/docs/en/costs). +#### 6) ๐Ÿ—œ๏ธ Compact at a natural boundary -#### 8) ๐Ÿ—œ๏ธ Compact deliberately +**Applies to:** Claude Code and Codex; argument syntax differs. -Compacting on your terms keeps what matters instead of letting auto-compaction guess. +Compact only when the same task still needs its earlier decisions and the context pressure justifies a summary. -1. Watch context use and act around 60โ€“70%. -2. Run `/compact` with focus instructions naming what to keep. +1. Preserve the current goal, accepted decisions, failing evidence, and next validation. +2. Use only the syntax documented by your client. + +| Client | Compact action | +| --- | --- | +| Claude Code | `/compact keep the accepted decisions, repro, and failing test` | +| Codex | `/compact`; no inline focus argument is documented | ```text -$ /compact keep the repro steps and the failing test; drop the file dumps +Claude Code: /compact keep the repro and failing test; drop file dumps +Codex: /compact ``` +See [Claude Code commands](https://code.claude.com/docs/en/commands) and [Codex commands](https://learn.chatgpt.com/docs/developer-commands?surface=cli). + ### ๐ŸŸก Intermediate -#### 9) ๐Ÿ—ฃ๏ธ Make the agent talk less +#### 7) ๐Ÿ“ˆ Export structured usage telemetry -Output is repetition you pay to generate, so cap the chatter. caveman forces short, filler-free replies (reported ~65% output cut, code intact) and auto-detects 30+ agents. +**Applies to:** Claude Code and Codex; their configuration and telemetry schemas differ. -1. Built-in route: set `"outputStyle": "concise"` in `settings.json`. -2. Harder cut: install the [`caveman`](https://github.com/JuliusBrussee/caveman) skill and invoke it like any skill โ€” `/caveman` (or `/caveman ultra`); stop with "normal mode". +Use your own OpenTelemetry collector when interactive usage commands are not enough for comparisons across sessions. -```text -/caveman +1. Enable the exporter for the selected client. +2. Keep prompt and tool content redacted unless an explicit audit requirement justifies collecting it. +3. Compare token types, model, agent, and tool output; treat cost attribution as an estimate unless it comes from the billing system. -before: The reason your React component is re-rendering is likely because you're creating a new object reference on each render cycle. When you pass an inline object as a prop, React's shallow comparison sees it as a different object every time, which triggers a re-render. I'd recommend using useMemo to memoize the object. +Claude Code metrics export: -after: New object ref each render. Inline object prop = new ref = re-render. Wrap in `useMemo`. +```bash +CLAUDE_CODE_ENABLE_TELEMETRY=1 \ +OTEL_METRICS_EXPORTER=otlp \ +OTEL_EXPORTER_OTLP_METRICS_ENDPOINT=http://localhost:4318/v1/metrics \ +OTEL_EXPORTER_OTLP_METRICS_PROTOCOL=http/protobuf \ +claude ``` -See [output styles](https://code.claude.com/docs/en/output-styles). +Codex log export in `config.toml`: -#### 10) ๐Ÿงน Filter noisy command output +```toml +[otel] +environment = "dev" +log_user_prompt = false -Test, install, and build logs flood context with lines the model never needs. +[otel.exporter."otlp-http"] +endpoint = "http://localhost:4318/v1/logs" +protocol = "binary" +``` -1. Install a CLI proxy: [`RTK`](https://github.com/rtk-ai/rtk) (Rust) or [`SNIP`](https://github.com/edouard-claude/snip) (Go, YAML filters). -2. Prefix your command with it: `rtk cargo test`. +Claude Code exports metrics such as `claude_code.token.usage`; Codex emits its own events and token fields. Do not query one client's schema under the other's names. -```mermaid -flowchart LR - A["rtk cargo test"] --> R[RTK proxy] - R --> C["cargo test runs"] - C -->|"~25,000 tokens"| R - R -->|"filter ยท group ยท dedupe"| M["~2,500 tokens to model"] -``` +See [Claude Code monitoring](https://code.claude.com/docs/en/monitoring-usage) and [Codex observability](https://learn.chatgpt.com/docs/config-file/config-advanced#observability-and-telemetry). + +#### 8) ๐Ÿ—ฃ๏ธ Make concise output explicit -Real saving: `git push` (15 lines, ~200 tokens) -> `rtk git push` (1 line, ~10 tokens). +**Applies to:** All coding agents as an instruction; persistent mechanisms are client-specific. -#### 11) ๐Ÿšซ Keep big paths out of context โ€” deny reads +Short answers reduce output tokens only when the instruction does not sacrifice required evidence. -Vendor dirs, build output, and secrets get pulled into context by accident. Deny reads on them so they stay out โ€” they remain grep-able. +1. Add one concise rule to the client-native instruction surface. +2. Use the client-specific output control only when its documented scope matches the goal. -1. In `settings.json`, add `Read(...)` deny rules for large or sensitive paths. -2. `.claudeignore` is not shipped โ€” deny rules are the official way. +| Client | Persistent mechanism | +| --- | --- | +| Claude Code | A short custom file under `.claude/output-styles/`, selected through `/config` | +| Codex | `model_verbosity = "low"` for supported Responses API models, plus a short rule in `AGENTS.md` | +| Other clients | A documented response-style setting or persistent instruction | -```json -{ - "permissions": { - "deny": ["Read(./vendor/**)", "Read(./dist/**)", "Read(./.env)"] - } -} +```text +Answer directly. Preserve code, decisive errors, evidence, and security warnings; omit filler. ``` -See [permissions](https://code.claude.com/docs/en/permissions). +`model_reasoning_summary = "concise"` in Codex shortens the reasoning summary, not the final answer. See [Claude Code output styles](https://code.claude.com/docs/en/output-styles) and [Codex configuration](https://learn.chatgpt.com/docs/config-file/config-reference). -#### 12) ๐Ÿ”Œ Prefer CLI over MCP +#### 9) ๐Ÿงน Filter noisy shell output selectively -An MCP server's schema rides along every turn; a CLI costs tokens only when you call it. Newer MCP tooling adds tool/context selection that loads only the tools you pick โ€” cheaper than before โ€” but a CLI is still leaner and faster. +**Applies to:** Shell-capable coding agents; RTK and SNIP are third-party tools. -| | CLI (`gh`, `acli`, โ€ฆ) | MCP server | -| --- | --- | --- | -| Token cost | a few, only when called | a schema every turn; less with tool/context selection | -| Speed | fastest | slower | -| Use when | a CLI exists | no CLI, or you need typed/live tool calls | +Reduce model-visible logs only when filtering cannot hide evidence needed for diagnosis. -See [`mcp-installation.md`](mcp-installation.md). +1. Prefer a command's native `--quiet`, `--json`, filtering, or targeted-test option. +2. If that is insufficient, inspect and install a proxy such as [`RTK`](https://github.com/rtk-ai/rtk) or [`SNIP`](https://github.com/edouard-claude/snip). +3. Prefix only materially noisy commands and rerun the raw command when the filtered result is incomplete. -### ๐Ÿ”ด Expert +```bash +rtk cargo test +``` -#### 13) ๐Ÿ”ฌ Audit which skills and tools run โ€” `Ctrl+O` +Published reduction figures measure model-visible command output, not independently verified billing savings. Never filter the first security failure or the only copy of a diagnostic log. -You optimise what you can see, so expand the transcript to watch what each turn actually invokes and pulls into context. +#### 10) ๐Ÿ”Œ Limit MCP exposure by client -1. Press `Ctrl+O` to toggle the transcript โ€” it shows detailed tool and skill usage and expands collapsed MCP calls. -2. Spot skills or tools that load on turns that don't need them, then scope or remove them. +**Applies to:** MCP-capable agents; deferral behavior is client-specific. -```text -Ctrl+O โ€” transcript expanded - โŽฟ Skill: token-optimization - โŽฟ Called slack 3 times โ†’ expanded: 3 tool calls -(illustrative โ€” replace with a screenshot of your real Ctrl+O transcript) +Disable unused servers and expose only required tools without assuming every MCP client has Claude Code Tool Search. + +1. Inventory enabled servers and tools. +2. Apply only controls documented by the selected client. + +| Client | Documented control | +| --- | --- | +| Claude Code | Tool Search defers MCP tool schemas on supported models and providers; avoid `alwaysLoad` unless a small toolset is needed on nearly every turn | +| Codex | Inspect with `/mcp verbose`; disable an unused server with `enabled = false`, or restrict it with `enabled_tools` and `disabled_tools` | +| Other clients | Disable unused servers or tools through their documented configuration; do not assume schema deferral | + +```toml +[mcp_servers.figma] +url = "https://mcp.figma.com/mcp" +enabled = false ``` -See the [keyboard shortcuts](https://code.claude.com/docs/en/interactive-mode). +Codex exposes no public stable setting equivalent to Claude Code's `alwaysLoad`. See [Claude Code MCP](https://code.claude.com/docs/en/mcp#scale-with-mcp-tool-search), [Codex MCP](https://learn.chatgpt.com/docs/extend/mcp?surface=cli), and [`mcp-installation.md`](mcp-installation.md). + +### ๐Ÿ”ด Expert -#### 14) ๐ŸŽฏ Route by difficulty +#### 11) ๐Ÿ”ฌ Inspect client behavior without mixing shortcuts -The top model on routine work is wasted spend, so pin the model per skill or agent โ€” cheap for routine, top-tier for hard reasoning. +**Applies to:** Claude Code for the commands below; Codex has no documented `/insights` equivalent. -1. Set `model` in a skill's or an agent's frontmatter (`haiku` / `sonnet` / `opus`, a full id, or `inherit`). -2. Give routine scouts a small model; reserve `opus` for the hard reasoning. +Use client-native diagnostics instead of copying shortcuts between products. -```yaml -# .claude/agents/explore.md โ€” routine scouting on a cheap model ---- -name: explore -description: Read-only codebase scout -tools: Read, Grep, Glob -model: haiku ---- +1. In Claude Code, run `/insights` for a session-pattern report. +2. In Claude Code, press `Ctrl+O` to expand the detailed transcript. +3. In Codex, use OTel or the visible transcript for analysis; do not use `Ctrl+O` as a Claude-style transcript toggle. + +```text +Claude Code: /insights +Claude Code: Ctrl+O ``` -A skill's `SKILL.md` takes the same `model:` field (e.g. `model: opus` for a heavy step). See [sub-agents](https://code.claude.com/docs/en/sub-agents) and [skills](https://code.claude.com/docs/en/skills). +In Codex CLI, `Ctrl+O` copies the latest completed response. The experimental `codex debug prompt-input [PROMPT]` command renders model-visible prompt inputs as JSON, but it is not an `/insights` replacement. + +#### 12) ๐ŸŽฏ Route model and reasoning by difficulty + +**Applies to:** Claude Code and Codex; configuration formats and command semantics differ. -#### 15) ๐Ÿงซ Offload high-volume work to subagents +Use the lowest model and reasoning level that passes a representative task, then raise them only for risk or complexity. -Test runs, log parsing, and wide exploration flood the main window. A subagent does it in its own context and hands back only a summary, so the bloat never lands in your session. +1. Route routine exploration separately from difficult implementation or review. +2. Use the configuration native to each client. -1. Define an agent in `.claude/agents/.md` with only the tools it needs and a small `model`. -2. Let it run the noisy op and return a short result. +| Client | Session control | Agent configuration | +| --- | --- | --- | +| Claude Code | `/model` and `/effort low` | `.claude/agents/*.md` or skill frontmatter with `model` and `effort` | +| Codex | `/model` and `/reasoning` | `.codex/agents/*.toml` with `model` and `model_reasoning_effort` | + +Claude Code agent frontmatter: ```yaml -# .claude/agents/test-runner.md --- -name: test-runner -description: Run the suite and return only the failures -tools: Bash, Read model: haiku +effort: low --- ``` -See [sub-agents](https://code.claude.com/docs/en/sub-agents). +Codex project agent: + +```toml +name = "explorer" +description = "Read-only codebase scout" +model = "gpt-5.6-terra" +model_reasoning_effort = "low" +``` + +Codex skills do not use Claude Code's `model` and `effort` frontmatter. See [Claude Code model configuration](https://code.claude.com/docs/en/model-config) and [Codex subagents](https://learn.chatgpt.com/docs/agent-configuration/subagents). + +#### 13) ๐Ÿงซ Isolate noisy work with subagents -#### 16) ๐ŸงŠ Protect your cache hits +**Applies to:** Coding agents with documented subagent support; configuration is client-specific. -Cached input bills far cheaper, and cache reads are most of your tokens (step 4) โ€” so don't throw the cache away mid-task. A model switch, an MCP connect or disconnect, or an effort change rebuilds it from scratch. +Use subagents for context isolation, parallelism, or specialist quality, not as an assumed reduction in total tokens. -1. Set the model and reasoning effort at the start of a task, not mid-work. -2. Switch model or toggle MCP servers only at task boundaries, where a cache rebuild is acceptable. +1. Delegate high-volume exploration, test logs, or independent review. +2. Ask for a short result containing only findings, evidence, and blockers. +3. Keep tightly coupled edits in one agent to avoid coordination overhead. ```text -mid-task model switch โ†’ cache invalidated โ†’ full re-bill -same model to a boundary โ†’ cache reads stay cheap +Delegate the test run to one subagent. Return only failing tests, the shortest decisive error, and the command used. ``` -See [prompt caching](https://code.claude.com/docs/en/prompt-caching). +Both Claude Code and Codex give subagents separate working context, but their own model calls still consume tokens and can increase total usage. See [Claude Code subagents](https://code.claude.com/docs/en/sub-agents) and [Codex subagents](https://learn.chatgpt.com/docs/agent-configuration/subagents). -#### 17) โœ… Cap extended thinking +#### 14) ๐ŸงŠ Protect Claude Code prompt-cache stability -Extended reasoning can silently add thousands of tokens on tasks that don't need it. +**Applies to:** Claude Code. No equivalent user-facing Codex cache-invalidation contract is documented here. -1. In `settings.json`, set `MAX_THINKING_TOKENS` to `0` for routine work. -2. See the [Claude Code settings docs](https://code.claude.com/docs/en/settings). +Keep the request prefix stable during one task so prompt caching can reuse it. -```json -{ - "env": { - "MAX_THINKING_TOKENS": "0" - } -} +1. Choose the model and effort before the first substantive prompt. +2. Change them mid-task only when the quality gain justifies a cache miss. +3. Keep MCP tools deferred; a change to tools loaded into the prefix can invalidate that layer. + +```text +/model sonnet +/effort medium ``` +For Codex, prompt caching is service-managed rather than a documented `config.toml` control; observe `cached_input` through Codex telemetry instead of transposing Claude settings. See [Claude Code prompt caching](https://code.claude.com/docs/en/prompt-caching) and [Codex observability](https://learn.chatgpt.com/docs/config-file/config-advanced#observability-and-telemetry). + ## In short -Measure first, then stack the cheap wins โ€” trimmed instructions, plan mode, a clean context, less chatter, filtered output โ€” before the advanced routing, subagents, and cache discipline. Most of the bill is cache and repetition; cut those and the cost follows. +Measure first, label every command by client, then reduce persistent instructions, stale history, noisy output, unnecessary tools, and excessive reasoning without hiding evidence or weakening quality. diff --git a/plugins/aidd-context/skills/12-cook/references/recipe-contract.md b/plugins/aidd-context/skills/12-cook/references/recipe-contract.md index f06f1bf0b..36cc62827 100644 --- a/plugins/aidd-context/skills/12-cook/references/recipe-contract.md +++ b/plugins/aidd-context/skills/12-cook/references/recipe-contract.md @@ -20,13 +20,14 @@ Rules for every recipe file the skill writes. ## Steps - The steps section heading is named after the goal: `## Steps to `, never a bare `## Steps`. +- Heading levels express nesting. Never skip a level: a heading may be at most one level deeper than the heading before it. - One step = one action: never bundle several tools or commands under one heading; split them. -- Each step is a `#### N) Title` heading, then one benefit-focused line of what and why in prose. Number steps continuously. +- A step directly under the steps section is a `### N) Title` heading. A step grouped under a `###` category is a `#### N) Title` heading. Number steps continuously. - Write the actions to take as a numbered list; write any description or indication as prose, never as a bullet. - For a tool: where it is, install it from its URL, then how to invoke it (its real command or slash invocation, e.g. `/caveman`). - Reuse the tool's canonical example captured verbatim from its site or README โ€” never a paraphrase, and never on the strength of a summary that says one exists. - Every step carries one concrete example. Prefer an image โ€” a screenshot or short video/GIF that matches the action โ€” over text whenever one exists; for a tool, use its official screenshot. Otherwise: a command with its real output, a config in the file's real syntax (valid JSON for `settings.json`, valid YAML for frontmatter, โ€ฆ), or a snippet. - A step that prefers one option over another uses a comparison table, not prose. - For a structural or flow concept (a proxy, a pipeline, an architecture), add a small Mermaid diagram with concrete example values. -- Level subheadings are optional. Group steps under `### ๐ŸŸข Beginner`, `### ๐ŸŸก Intermediate`, `### ๐Ÿ”ด Expert` only when the recipe spans difficulty levels and grouping helps the reader; a short or single-level recipe lists its steps directly. Include only the levels that have a step. +- Level subheadings are optional. Group steps under `### ๐ŸŸข Beginner`, `### ๐ŸŸก Intermediate`, `### ๐Ÿ”ด Expert` only when the recipe spans difficulty levels and grouping helps the reader; their steps use `####`. A short or single-level recipe lists its steps directly with `###`. Include only the levels that have a step. - Link to a reference when applicable.