Writing skills

From PostHog/posthog · View interactive version

Writing skills is an AI agent skill from the GitHub repository PostHog/posthog. Guide for writing PostHog agent skills — job-to-be-done templates that teach agents how to use MCP tools to achieve a goal. Use when adding new product functionality that agents should know how to work with, creating a new skill, or updating existing skills in products/*/skills/ or .agents/skills/.

How to use this skill

Skill file

Writing skills for PostHog agents

Read the full guide at docs/published/handbook/engineering/ai/writing-skills.md.

Choose a location

hogli lint:skills checks both locations. The scaffold, build, and sync commands below apply to published product skills.

Quick workflow

# 1. Scaffold
hogli init:skill

# 2. Write your skill in products/{product}/skills/{skill-name}/SKILL.md

# 3. Lint
hogli lint:skills

# 4. Build to verify
hogli build:skills

# 5. Test locally with PostHog Desktop or a coding agent
hogli sync:skill -- --name <skill-name>

# 6. Delete the test skill (optional)
hogli unsync:skill -- --name <skill-name>

Distribution is automatic after merge — CI publishes to PostHog/skills.

This repo is not the only source. CODE0 publishes the omnibus skills — instrument-integration, instrument-product-analytics, instrument-feature-flags, instrument-error-tracking, instrument-llm-analytics, instrument-logs, instrument-metrics — and every shipping consumer overlays them on top of this repo's, so context-mill wins on a same-named skill. hogli lint:skills fails if you add one of those names under products/*/skills/; change the context-mill source instead. Local builds are the opposite case: they carry no omnibus skills at all, so anything that depends on one has to overlay it or fail loudly. See Context-mill skills override this repo's for the merge sites.

When to write a skill

When new functionality is added to a product and agents need to know how to work with it.

A skill is not about what tools exist (that's the MCP server) —

it's about how an experienced person would approach a job using those tools.

Ask: "If a customer asked an agent to do X with my feature, would the agent know the right approach?"

If not, write a skill.

Docs or skill?

A skill holds only what an agent needs on top of the docs: the steps of one job, the checks before it reports done, and the decisions it must not make alone.

How a system works, its setup, options and gotchas go in docs (a README next to the code, or an existing page under docs/), and the skill links to them.

If an engineer would look it up without an agent, it is docs.

How many is too many?

Skill count is a budgeted, shared resource — agents pick from a list of _all_ skill descriptions, and many harnesses truncate that list once it grows long, so every extra skill makes the others less likely to fire.

Prefer a small set of focused skills, each with rich references/, over many thin ones:

Key rules

Skill structure

products/{product}/skills/{skill-name}/
    SKILL.md                         # entry point (required)
    references/                      # optional
        guidelines.md
        models-foo.md
        example-bar.md.j2            # Jinja2 template, rendered at build time
    scripts/                         # optional
        setup.sh

Only references/ and scripts/ subdirectories are collected. Others are ignored.

Template functions

Files ending in .j2 are rendered with Jinja2 at build time

by CODE0.

Extend the build pipeline so the monorepo stays the source of truth —

when domain knowledge lives in code (Pydantic models, query runners, function registries),

add a template function rather than duplicating it as static markdown that drifts.

Available functions:

Good example: `querying-posthog-data`

Bad example: `llm-analytics`

An umbrella skill covering traces, experiments, evaluations, cost tracking, prompt management.

Too broad — agents can't determine when to activate it. Break into focused skills instead.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.