Skip to content
Data
Agent

resource-duplication

Resource duplication expert - use when configuring a resource to be copied between projects.

From plugin
posthog
41k11 skills11 agents2 commands3 MCP

Claude Code

$ npx -y skills add posthog/posthog --agent claude-code

Agent definition

resource-duplication.md
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

Resource duplication

Your goal is to implement the configuration required to allow Django models to be copied from one team (project) to another.

Background

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.

Core concepts

Overview

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).

Visitors

`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:

  • The `kind` of the resource, referred to as `scope` in other parts of the code base like activity logs. Often just the name of the Django model.
  • The fields that should be excluded when duplicating a resource (`excluded_fields`).
  • If the resource should be allowed to be duplicated or left untouched (`immutable`).
  • If the resource should be shown in the UI (`user_facing`).
  • What is the Django model for the resource.
  • What is the team for the resource.
  • ...and more

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.

Excluded fields

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.

Dynamic edges

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.

Immutable resources

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.

User facing resources

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.

Required parameters for visitor classes

The following is required in each class:

  • The `kind` meta parameter
  • An implementation of the `get_model` class method

Example

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 Foo

If 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
Read more
@posthog
Ships withposthog

: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.

41k172 skills11 agents3 MCP
Get the whole plugin

Stars on GitHub

Momentum

stars in total
40.7k
Star history of posthog/posthog on GitHub, a chart by star-history.com

Other agents on posthog.

access-control

access-control

Agent

PostHog access control system implementation expert - use when adding access controls to new products, debugging access control…

@posthog@posthogInstall Agent
activity-log-expert

activity-log-expert

Agent

Use this agent when working with PostHog's activity logging (audit trail) system - adding activity logging to a model, writing or…

@posthog@posthogInstall Agent
code-reviewer

code-reviewer

Agent

Use this agent when you need expert code review of recently written or modified code. This agent should be invoked after…

@posthog@posthogInstall Agent
pipeline-result-doctor

pipeline-result-doctor

Agent

Ingestion pipeline result handling convention checker. Use when working with result constructors (ok/dlq/drop/redirect), side…

@posthog@posthogInstall Agent
pipeline-step-doctor

pipeline-step-doctor

Agent

Ingestion pipeline step convention checker. Use when writing, reviewing, or refactoring individual pipeline steps — covers…

@posthog@posthogInstall Agent

More agents from other plugins.

sidekick
Auto-invoked

sidekick

Agent

A Sonnet coding agent that works in a separate Git worktree and keeps its own conversation. Use it when it can investigate,…

mem05d69k
@mem0ai@mem0aiInstall Agent
backend-dev

backend-dev

Agent

MemOS backend / library implementation sub-agent. Writes code under src/memos/ within the task boundary, strictly TDD, then…

memos13d12k
@memtensor@memtensorInstall Agent
godev

godev

Agent

PROACTIVELY handles Go code writing, reviews, refactoring, component architecture, registration, and multi-distribution builds…

connecttoday8.8k
@redpanda-data@redpanda-dataInstall Agent

Questions about resource-duplication.

Which coding agents can use resource-duplication?
resource-duplication installs in Claude Code and Cursor: each loads subagents from .claude/agents, so copy the file there. Flowy's auto-invocation runs in Claude Code only.