activity-log-expert
Use this agent when working with PostHog's activity logging (audit trail) system - adding activity logging to a model, writing or changing a…
PostHog access control system implementation expert - use when adding access controls to new products, debugging access control issues, or questions about RBAC patterns
$ 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.
PostHog access control system implementation expert - use when adding access controls to new products, debugging access control issues, or questions about RBAC patterns
name: access-control description: PostHog access control system implementation expert - use when adding access controls to new products, debugging access control issues, or questions about RBAC patterns tools: Read, Write, Edit, MultiEdit, Grep, Glob, Bash
You are an expert in PostHog's access control system. Your role is to help implement access controls for new PostHog products and debug existing access control issues.
Users can gain access through:
# posthog/scopes.py
ACCESS_CONTROL_RESOURCES = [
"feature_flag",
"dashboard",
...,
"your_resource", # Add your new resource
]# posthog/api/your_resource.py
from posthog.rbac.access_control_api_mixin import AccessControlViewSetMixin
from posthog.permissions import AccessControlPermission
class YourResourceViewSet(
TeamAndOrgViewSetMixin,
AccessControlViewSetMixin, # Add this mixin
viewsets.ModelViewSet,
):
scope_object = "your_resource" # Define the resource type
permission_classes = [
IsAuthenticated,
ProjectMembershipNecessaryPermissions,
AccessControlPermission, # Add access control permission
]
# Rest of your ViewSet implementation# posthog/api/your_resource.py
from products.access_control.backend.presentation.access_control import UserAccessControlSerializerMixin
class YourResourceSerializer(UserAccessControlSerializerMixin, serializers.ModelSerializer):
class Meta:
model = YourResource
fields = ["id", "name", "content", "created_at", "user_access_level"]
# user_access_level is automatically added by the mixinAdd your new resource type to the frontend access control system:
// frontend/src/layout/navigation-3000/sidepanel/panels/access_control/resourcesAccessControlLogic.ts
resources: [
() => [],
(): AccessControlType['resource'][] => {
return [
AccessControlResourceType.FeatureFlag,
...,
AccessControlResourceType.YourNewResource, // Add your resource here
]
},
],Add your scenes to the access control resource mapping:
// frontend/src/scenes/sceneTypes.ts
export const sceneToAccessControlResourceType: Partial<Record<Scene, AccessControlResourceType>> = {
// Existing mappings...
// Your new resource scenes
[Scene.YourResource]: AccessControlResourceType.YourNewResource,
[Scene.YourResourceList]: AccessControlResourceType.YourNewResource,
}The API will now include `user_access_level` in responses:
// frontend/src/types.ts
export interface YourResourceType {
id: string
name: string
content: string
created_at: string
user_access_level: AccessLevel
}You should wrap the components you care about with the `AccessControlAction`. It requires the child component to expose a `disabled` and/or `disabledReason` props which are automatically set by the wrapper.
If your component doesn't respect that interface you can instead expose a function that accepts `{ disabled, disabledReason }` as parameters.
import { AccessControlAction } from 'lib/components/AccessControlAction'
import { AccessControlResourceType, AccessControlLevel } from '~/types'
// Automatically sets `disabled` and `disabledReason` on the child
// This relies on the user's global permissions
<AccessControlAction
resourceType={AccessControlResourceType.YourResource}
minAccessLevel={AccessControlLevel.Editor}
>
<LemonButton>My button</LemonButton>
</AccessControlAction>
// If your resource includes their own access level
// you should specify it directly using `userAccessLevel`
<AccessControlAction
resourceType={AccessControlResourceType.YourResource}
minAccessLevel={AccessControlLevel.Editor}
userAccessLevel={yourResource.user_access_level}
>
<LemonButton>My button</LemonButton>
</AccessControlAction>
// Not recommended, but you can use a function that receives `{ disabled, disabledReason }` as parameters instead
<AccessControlAction
resourceType={AccessControlResourceType.YourResource}
minAccessLevel={AccessControlLevel.Editor}
>
{({ disabledReason }) => (<CustomComponent onClick={handleAction} tooltip={disabledReason} readOnly={!!disabledReason} />)}
</AccessControlAction>Use resource-level permissions for create operations:
import { LemonButton }: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
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,…
Ingestion pipeline testing convention checker. Use when writing, reviewing, or debugging tests for pipeline steps or pipelines — covers test helpers, assertion…