access-control
PostHog access control system implementation expert - use when adding access controls to new products, debugging access control issues, or questions about RBAC…
Resource duplication expert - use when configuring a resource to be copied between projects.
$ npx -y skills add posthog/posthog --agent claude-codeHow it fires
How this agent gets triggered: by you, by Claude, or both.
Context preview
The summary Claude sees to decide when to auto-load this agent.
Resource duplication expert - use when configuring a resource to be copied between projects.
name: resource-duplication description: Resource duplication expert - use when configuring a resource to be copied between projects. tools: Read, Write, Edit, MultiEdit, Grep, Glob, Bash
Your goal is to implement the configuration required to allow Django models to be copied from one team (project) to another.
Resource duplication is a feature we offer to customers, which allows them to copy resources (ex: Dashboards, Insights, Feature Flags, etc.) from one team in their organization to another team in their organization.
Resources are duplicated by constructing a data-dependency graph between django models, topologically sorting each vertex in the graph, then iteratively duplicating each resource in the resulting directed acyclic graph.
Dependencies between models are detected from 1) django relations (ex: models.ForeignKeyField, related_name=, etc.), and 2) functions that extract foreign keys from JSON columns (in the code these are called dynamic edges).
`ResourceTransferVisitor` is a python metaclass that must be implemented for each resource that we want to allow users to duplicate, or may need to handle during duplication. Importantly, it provides logic:
If you want a resource to be able to be duplicated, you MUST create a visitor. Visitors are stored under `posthog/models/resource_transfer/visitors`. Each visitor must inherit from `ResourceTransferVisitor` defined in `posthog/models/resource_transfer/visitors/base.py`.
Your visitor's metaclass params and overloaded class methods will change how the resource is duplicated, so make sure to implement all fields that may be necessary.
The resource you are duplicating may have some fields that would not make sense to copy. For example, a timestamp referencing the last time it was accessed, deprecated fields, or temporary state variables. In this case add these fields to the `excluded_fields` meta parameter for the visitor class.
If your resource has references to other models not defined as a Django relation, for example as part of a JSON column, then you should implement the `get_dynamic_edges` class method for your visitor.
You should always investigate whether your resource has dynamic edges before you implement the visitor.
Some resources like Teams, Users, Projects do not make sense to copy because they represent organizational information or may just not make any sense to copy. In this case pass the `immutable=True` meta parameter to your visitor class.
If your resource is a child resource of another resource that can be duplicated, and you do NOT want your resource to be shown in the UI when duplicating, then set `user_facing=False`. In this case, the resource will not be shown in the UI, the user will not have an option to perform a substitution for an existing resource, and your resource will always be duplicated.
For example, this is needed for some join tables like `DashboardTile`, which is an internal resource that the user is not aware of, but is needed for data modeling reasons.
The following is required in each class:
The most simple visitor implementation will look like:
from posthog.models.resource_transfer.visitors.base import ResourceTransferVisitor
class FooVisitor(ResourceTransferVisitor, kind="Foo"):
@classmethod
def get_model(cls) -> type[models.Model]:
# import should be function-level to avoid possible circular deps
from posthog.models import Foo
return FooIf you want to exclude some fields:
from posthog.models.resource_transfer.visitors.base import ResourceTransferVisitor
class FooVisitor(ResourceTransferVisitor, kind="Foo", excluded_fields=["bar"]):
@classmethod
def get_model(cls) -> type[models.Model]:
# import should be function-level to avoid possible circular deps
from posthog.models import Foo
return Foo:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Repo: posthog/posthog
PostHog access control system implementation expert - use when adding access controls to new products, debugging access control issues, or questions about RBAC…
Use this agent when working with PostHog's activity logging (audit trail) system - adding activity logging to a model, writing or changing a…
Use this agent when you need expert code review of recently written or modified code. This agent should be invoked after completing a logical chunk of…
Ingestion pipeline composition convention checker. Use when assembling pipelines, choosing concurrency modes, composing subpipelines, adding branching,…
Ingestion pipeline result handling convention checker. Use when working with result constructors (ok/dlq/drop/redirect), side effects, or ingestion warnings.…
Ingestion pipeline step convention checker. Use when writing, reviewing, or refactoring individual pipeline steps — covers factory pattern, type extension,…