profiling-slow-api-endpoints

profiling-slow-api-endpoints is a skill for Claude Code, Codex from PostHog/posthog-foss. It costs 113 tokens per session (874 once invoked), scanned A, original, MIT.

A procedure for finding why PostHog API requests are slow when the work is mainly in Python or PostgreSQL. It compares the same user action before and after a change using traces, query details, and latency measurements.

In plain words
What is it for?
It helps investigate slow screens, pickers, lists, and Django endpoints; inspect PostgreSQL query plans; and gather production evidence for database changes.
Why use it?
It avoids optimizing the wrong function or query by tracing the delay from the user action to the code and database work that causes it.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one. Also seen: installed under .agents/ (shared by several agents).

Good fit It helps investigate slow screens, pickers, lists, and Django endpoints; inspect PostgreSQL query plans; and gather production evidence for database changes.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/posthog/posthog-foss/profiling-slow-api-endpoints
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add PostHog/posthog-foss --skill profiling-slow-api-endpoints
Clone the repo
git clone --depth 1 https://github.com/PostHog/posthog-foss

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for profiling-slow-api-endpoints

README.md
[![agentmods](https://agentmods.dev/badge/skills/posthog/posthog-foss/profiling-slow-api-endpoints/github.svg)](https://agentmods.dev/skills/posthog/posthog-foss/profiling-slow-api-endpoints)
Your own site
<a href="https://agentmods.dev/skills/posthog/posthog-foss/profiling-slow-api-endpoints"><img src="https://agentmods.dev/badge/skills/posthog/posthog-foss/profiling-slow-api-endpoints/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for profiling-slow-api-endpoints

Your own site · 80×15
<a href="https://agentmods.dev/skills/posthog/posthog-foss/profiling-slow-api-endpoints"><img src="https://agentmods.dev/badge/skills/posthog/posthog-foss/profiling-slow-api-endpoints.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 113 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 874 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00113 $0.00874
Opus 5.5 $0.00045 $0.00350
Sonnet 5.5 $0.00023 $0.00175
Haiku 4.5 $0.00011 $0.00087

Measured 2mo ago against content hash 34d3f567877f, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

profiling-slow-api-endpoints scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2mo ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.agents/skills/profiling-slow-api-endpoints/SKILL.md · 92 lines

How it starts

The opening of the file, as written. The whole thing — 92 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Profiling slow API endpoints

Use this skill when a PostHog API request spends most of its time in Postgres or Python. For ClickHouse and HogQL, use optimizing-clickhouse-and-hogql-queries.

Measure the same user action before and after the change. A faster query does not help if the action stays slow.

Find the source of the delay

Record the page action, endpoint, request shape, affected users, request volume, and a latency percentile such as p95. Read slow APM traces with posthog:query-apm-spans and the exploring-apm-traces skill. The distribution shows how often requests are slow. The traces show where they spend time.

  • Django ORM and cursor.execute spans point to Postgres.
  • ClickHouse work belongs in the ClickHouse skill.
  • Time outside database spans can indicate repeated calls, serialization, or excess data loading.

Follow the request to the function that creates the work. Do not optimize a view wrapper when another function owns the delay.

Capture the exact work

Get the SQL and parameters from a slow request. Keep its filters, ordering, and page size. Check for repeated queries, count queries, and work that does not block the response. A reduced query can use a different plan. Local data and statistics can also produce a different plan.

Use querying-production-databases-via-metabase to inspect the production read replica. Start with EXPLAIN. Use EXPLAIN (ANALYZE, BUFFERS) only when the exact SELECT is safe to run. Inspect row estimates, indexes, join types, loops, filters, sorts, and buffer use.

Compare the smallest useful change

Remove work that the response does not need before you change a query or add an index. Compare the original and candidate with the same parameters. Run each more than once, record the cache state, and verify equal results.

Measure the tenant-size distribution when plans can change with tenant size. Test both sides of a plan crossover before you select a threshold. One tenant is not enough evidence for a conditional plan.

Read the full file on GitHub · 92 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2mo ago First seen · 92 lines · 113 tokens per session scan A 34d3f567877f

Subscribe to this mod's changes

profiling-slow-api-endpoints is a skill published in the GitHub repository PostHog/posthog-foss (736 stars, last pushed today), licensed MIT. It adds 113 tokens to every session and 874 once invoked, about $0.0005 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-08.

Related

profiling-slow-api-endpoints compared with skills from other repositories

profiling-slow-api-endpoints next to 6 skills from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
profiling-slow-api-endpointsPostHog/posthog-fossSkill736todayMITA113Claude Code, Codex
systematic-debuggingopen-metadata/OpenMetadataSkill16ktodayApache-2.0A37Claude Code
log-error-digestzebbern/claude-code-guideSkill4.7ktodayMITA71Claude Code, Codex
observability-audit-sessionsIBM/mcp-context-forgeSkill4.9ktodayApache-2.0A64Claude Code, Codex
cwv-optimizeradobe/skillsSkill343todayApache-2.0A112Claude Code
performance-verificationvalkor-ai/loomSkill1.6k2d agoApache-2.0A45Claude Code, Codex
loop-engineeringhuytieu/COG-second-brainSkill1.6ktodayMITA63Claude Code