
Establishing Code Ownership
FreeIdentify code ownership across your PostHog projects.
Free · Opens the source repo
What Establishing Code Ownership does
Establishing Code Ownership is a skill designed to help teams working with PostHog manage and understand code ownership efficiently. By utilizing the hogli owners:* command, users can quickly determine which team owns a specific file or directory within their codebase. This is particularly useful when assigning reviewers, attributing bugs, or routing work to the appropriate teams. The tool leverages distributed ownership files, including owners.yaml, product.yaml, and .github/CODEOWNERS, to provide accurate ownership information without the need for manual parsing.
The skill operates by resolving ownership through a well-defined algorithm that prioritizes the nearest ownership file. It starts from the root of the repository and collects ownership data, merging it according to specified rules. This ensures that users receive the most relevant ownership information for the code paths they are investigating. The command-line interface allows for quick queries, such as finding out who owns a particular path or listing all unowned files, making it a powerful tool for developers and project managers alike.
For teams looking to maintain accountability and streamline their code review process, this skill provides a clear overview of ownership across both backend and frontend code. It also aids in scoping audits and understanding team responsibilities, which is crucial in collaborative environments. By integrating this skill into their workflow, teams can enhance their productivity and ensure that code ownership is clearly defined and easily accessible.
However, it is important to note that this skill does not provide a single command for mapping teams to files directly; users will need to combine several commands to filter ownership by team slug. Additionally, the .github/CODEOWNERS file is not included in the ownership resolution process, which may require separate consultation for GitHub-specific approvals.
When to use it
Use this skill when you need to identify the owner of a specific file or directory, especially during code reviews or bug attribution.
When not to use it
This skill may not be suitable for projects outside of PostHog or for users not working with the specified ownership files.
What you can build with it
Assigning Code Reviewers
Quickly determine which team owns a file to assign the appropriate reviewer during the code review process.
Attributing Bugs
Identify the team responsible for a bug by checking the ownership of the affected code paths.
Scoping Team Audits
Use the ownership data to scope audits and understand team responsibilities across the codebase.
How to install Establishing Code Ownership
View source1. Install with the skills CLI
npx skills add posthog/posthog/establishing-code-ownership --agent claude-code2. Or install it manually
Download the skill folder and drop it into ~/.claude/skills/ for all projects, or .claude/skills/ to scope it to one repo. Restart Claude Code so it picks up the new skill.
Anthropic's agentic coding CLI, and the reference implementation of Agent Skills. Drop a skill folder into ~/.claude/skills and Claude Code loads it automatically whenever a task matches the skill's description. Claude Code docs
Inside SKILL.md
Written by posthogEstablishing code ownership
Ownership is resolved by one tool — hogli owners:* — over distributed owners.yaml files.
Don't re-parse the ownership files by hand; the resolver owns the semantics and is what CI enforces.
Fast path: hogli owners:*
Dev machines have flox/hogli, so shell straight to the resolver.
hogli owners:who posthog/hogql/printer.py # who owns this path (+ the file that decided it)
hogli owners:resolve --json posthog/api/survey.py products/surveys/backend/api.py # batch, JSON keyed by path
hogli owners:unowned # every tracked file with no owner (append a prefix to scope: `owners:unowned products/`)
owners:who prints the resolved owners, the status, the Slack channel, and source — the owners.yaml/product.yaml file that decided the answer.
The channel comes from the root teams: registry entry for the primary owner, else a derived #<slug>; a path whose primary owner is an @handle has no channel.
owners:resolve takes paths as arguments or newline-delimited on stdin, so you can pipe a file list: git ls-files posthog/hogql | hogli owners:resolve --json.
No hogli/flox available? The dependency-light fallback needs only pyyaml: git ls-files posthog/hogql | PYTHONPATH=tools/owners python -m posthog_owners (stdin paths → the same JSON).
Resolution algorithm (what the resolver does)
For a path, it walks from the repo root down to the path collecting ownership files, then merges them nearest-file-wins:
owners.yaml— the canonical, distributed source. Each directory can carry one. Fields (owners,status,inherit, per-pathrules) fall through to the nearest ancestor unless overridden.inherit: falsecuts the walk (Gerrit'sset noparent) — nothing above it contributes. Within a file,rules:are last-match-wins.owners: nullmeans unowned by design (exempt from the coverage check), distinct from a directory with no file at all (genuinely unowned).products/<name>/product.yaml— an accepted alias. When a product dir has noowners.yaml, itsproduct.yamlowners:list is read as the ownership forproducts/<name>/**(every otherproduct.yamlfield is ignored). A dir with both files is a lint error;owners.yamlwins..github/CODEOWNERS— blocking approvals, never part of the walk. It keeps GitHub-native semantics, stays hand-maintained (mostly infra, e.g.team-security), and is enforced by GitHub itself. The resolver does not read it — when you need to know whether a blocking approval is additionally required, consult the file directly. It never changes the resolvedowners, and nothing here writes to it.
Owners are a mixed list of team slugs (team-devex, conversations, logs — the GitHub team handle minus @PostHog/) and @handles for individuals; the first entry is the primary owner.
team → code (what does this team own?)
There's no single "team → files" command; resolve the tree and filter by slug:
git ls-files | hogli owners:resolve --json | jq -r 'to_entries[] | select(.value.owners | index("team-surveys")) | .key'
Also grep products/*/product.yaml for the slug — each hit is all of that products/<name>/**; one team often owns several, so don't stop at the first.
Owned paths span backend and frontend/src/...; cover both, or say up front you're doing one side.
Generated files
A generated artifact often resolves to a broad parent owner or nobody.
Trace it to the input it's generated from and report that team as the logical owner (e.g. services/mcp/src/tools/generated/<x>.ts comes from products/<name>/mcp/tools.yaml).
Distinguish the logical owner (the team owning the source — the answer to report) from the literal resolver result on the generated path, and flag the gap so the operator can decide whether to pin it with a rules: entry.
Last resort: feature-ownership handbook, then Slack
If neither the resolver nor product.yaml resolves it, consult the feature-ownership handbook — coarse-grained (broad areas, not files) and hand-maintained, so prefer the repo files and flag any handbook-sourced answer as possibly stale.
If even that fails and the Slack MCP is available, search Slack — least authoritative (opinions, stale threads), so verify against the repo files and flag the answer as Slack-sourced.
Slug vs handle
- Handle (
CODEOWNERS):@PostHog/<slug>, e.g.@PostHog/team-replay. - Slug (
owners.yaml/product.yaml): handle minus@PostHog/, e.g.team-replay. - Not uniform: some carry
team-(team-self-driving), some don't (conversations,logs). If a name doesn't resolve, try both forms.
Frequently asked questions about Establishing Code Ownership
Similar skills
Quality Playbook Generator
Run comprehensive quality audits on any codebase.
PR Draft Summary
Automate PR summary generation for openai-agents-python.
Final Release Review
Streamline your release candidate audits with ease.
Unit Test Vue Pinia
Efficiently write and review unit tests for Vue 3 applications.
Slang Shader Expert
Optimize and integrate Slang shaders with ease.
Telemetry Standards
Ensure consistent event tracking in Supabase Studio.
