Back to Skills

implementing-agent-modes

Guidelines to create/update a new mode for PostHog AI agent. Modes are a way to limit what tools, prompts, and prompt injections are applied and under what conditions. Achieve better results using your plan mode.

35,376stars2,935forksUpdated 7/8/2026

Security Assessment

Safe(100/100)
Security Score100/100

About implementing-agent-modes

Guidelines for creating or updating a mode for the PostHog AI agent. A mode is a way to manage the agent's context by scoping which tools, prompts, and prompt injections apply and under what conditions, so the agent produces better results for a specific product, product area, or job-to-be-done. The agent can move between modes with its switch_mode tool, which swaps tools, prompt, and executables while preserving the current context. Because some tools are contextual (injected only on particular frontend pages), modes provide a consistent way to always carry the right tools in context.

The workflow walks through concrete steps in the PostHog codebase: exploring ee/hogai/core/agent_modes/presets to check for an existing matching mode; optionally adding a new AgentMode to the schema and regenerating it (hogli build:schema or pnpm run schema:build); building the mode scaffolding as an AgentToolkit (tools plus JTBD-style trajectory examples) and an AgentModeDefinition (the mode description injected into context, plus toolkit and executable classes); wiring in tools from ee/hogai/tools or products/<product_name>/backend/max_tools; and reviewing the default read_data, search, and list_data tools for any new Django models. It emphasizes checking tool dependencies, looping back to the user about merging modes when tools depend on each other, and keeping tools backend-first so the agent retains proper context.

Use it when planning or implementing a new agent mode, or updating an existing one. It also covers the frontend side, updating max-constants.tsx, adding the mode to the mode selector, and building UI to display tool output, and mandates that all new modes be feature-flagged, including guidance that migrated tools be hidden when a flag is active while new tools appear only when it is. The final step is implementing and updating tests for new tools, presets, and executables, with optional evals.

FAQ

What is an agent mode in this context?

A way to manage the PostHog AI agent's context by limiting which tools, prompts, and prompt injections apply and under what conditions, scoped to a product, product area, or agent.

How does the agent move between modes?

It uses the switch_mode tool, which can change the tools, prompt, and executables while preserving the current conversation context.

What are the two main pieces a mode should contain?

An AgentToolkit exposing mode-specific tools plus trajectory examples for the todo tool, and an AgentModeDefinition containing the AgentMode, its always-injected description, and toolkit/executable classes.

Are new modes required to be feature-flagged?

Yes. All new modes must be feature-flagged; migrated old tools should be unavailable when the flag is active, and new tools should be available only when it is.

Where do the tools for a mode come from?

Relevant tools live in ee/hogai/tools or products/<product_name>/backend/max_tools, with an always-injected set like read_data, while all other tools should be specific to the mode.

Install implementing-agent-modes

Download and extract the skill files to your .claude/skills/ directory.

Quick Setup:

  1. Copy the skill folder to .claude/skills/
  2. Claude will automatically detect and use the skill

Repository

posthog/posthog