Official agent skill

Adding Activity Logging

by PostHog in PostHog/posthog-foss

Adds or changes activity logging (the audit trail) for a Django model in PostHog.

OfficialMITAuto-check passedBackend & APIs

Install Adding Activity Logging

skills CLI
$ npx skills add PostHog/posthog-foss --skill adding-activity-logging -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install PostHog/posthog-foss adding-activity-logging --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/PostHog/posthog-foss.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.agents/skills/adding-activity-logging .claude/skills/adding-activity-logging && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
adding-activity-logging
GitHub stars
721
Token cost
~1.5k tokens
SKILL.md length
642 words
Files
1
Skills in repo
213
Repo updated
First seen
Licence
MIT

At a glance

Adds or changes activity logging (the audit trail) for a Django model in PostHog.

  • Works in 9 steps: Find every write path before you touch… → Model and scope → Receiver module → …
  • A models writes must show in the Activity side panel
  • SKILL.md covers Step 1 - Find every write path…, Step 2 - Model and scope, Step 3 - Receiver module and Step 4 - Wire it, plus 7 more sections
  • Calls rg and ruff

What it does

Adding Activity Logging is an agent skill from PostHog/posthog-foss, published by the product's own GitHub organization. Adds or changes activity logging (the audit trail) for a Django model in PostHog. Use when a model's writes must show in the Activity side panel or the advanced activity logs, when adding ModelActivityMixin, an ActivityScope, a modelactivitysignal receiver, an activity describer, or field exclusions, when auditing which write paths of a model are logged, or when a change is missing from the activity log. Covers the receiver-module convention, writes the signal cannot see (QuerySet.update, bulkcreate), the actor…

Its SKILL.md is about 1.5k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in Backend & APIs, covering Backend development. It works with PostHog and Django. The repository describes itself as: PostHog FOSS is a read-only mirror of PostHog, with all proprietary code removed. NOTE: This repo is synced automatically from the main PostHog repo. Please raise any issues and… The licence is MIT.

When your agent uses it

  • A models writes must show in the Activity side panel
  • The advanced activity logs
  • Adding ModelActivityMixin
  • An ActivityScope

Example prompts

  • “/adding-activity-logging”

Workflow steps

9 steps, taken from the step headings in SKILL.md.

  1. Find every write path before you touch the model
  2. Model and scope
  3. Receiver module
  4. Wire it
  5. Bulk writes
  6. Separate-database products only
  7. Tune the diff
  8. Describer (optional)
  9. Tests

What it can do on your machine

Read from SKILL.md and the folder at commit 2c48221. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • rg
    • ruff

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Adding Activity Logging loads about 1.5k tokens when it runs. Until then it costs about 187 tokens; SKILL.md has 642 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~187
When it runs · the whole SKILL.md, loaded when a task matches
~1.5k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from PostHog/posthog-foss at commit 2c48221, republished under its MIT licence (© PostHog). 642 words, ~1,540 tokens.

Download SKILL.mdSave it as .claude/skills/adding-activity-logging/SKILL.md (or your agent's skills folder).
name
adding-activity-logging
description
Adds or changes activity logging (the audit trail) for a Django model in PostHog. Use when a model's writes must show in the Activity side panel or the advanced activity logs, when adding ModelActivityMixin, an ActivityScope, a model_activity_signal receiver, an activity describer, or field exclusions, when auditing which write paths of a model are logged, or when a change is missing from the activity log. Covers the receiver-module convention, writes the signal cannot see (QuerySet.update, bulk_create), the actor outside requests, and product models on a separate database. Trigger terms - activity log, audit log, audit trail, ModelActivityMixin, log_activity, changes_between, activity describer, who changed this.

Adding activity logging

Read docs/internal/activity-logging.md first. It carries the pipeline, the file locations, and the reasons. This skill carries the workflow and the gates.

Reference implementation: products/feature_flags/backend/activity_logging.py with its apps.py. Separate-database reference: products/stamphog/backend/activity_logging.py.

Step 1 - Find every write path before you touch the model

The mixin hooks save() and delete(). It does not see QuerySet.update(), bulk_create(), bulk_update(), or raw SQL. A receiver that logs only the API path gives an audit trail that says nobody changed a row a webhook changed.

sh
rg -n "Thing\.objects|Thing\.all_teams" products/<name>/ --type py | rg -v "tests/"
rg -n "\.update\(|bulk_create\(|bulk_update\(" products/<name>/backend --type py

Write the list down: which paths call save() (the mixin covers them) and which do bulk writes (you log those by hand in step 5). Include tasks, Temporal activities, webhook handlers, and management commands.

Step 2 - Model and scope

  • Add ModelActivityMixin first in the bases: class Thing(ModelActivityMixin, TeamScopedRootMixin, ...).
  • Set activity_logging_on_delete = True only when a hard delete must show in the log.
  • Add the class name to ActivityScope in posthog/models/activity_logging/activity_log.py.
  • Add the same string to the ActivityScope enum in frontend/src/types.ts.
  • Run hogli build:openapi (needs the dev stack) because the API scope filter enum is generated from the Literal.

No migration is needed. The mixin adds no field.

Step 3 - Receiver module

Create products/<name>/backend/activity_logging.py. One @mutable_receiver(model_activity_signal, sender=Thing) per model. The receiver calls changes_between and log_activity; nothing else.

Keep the module import-light. It must not import a viewset, a serializer, or a query runner. ready() imports it at django.setup() in every process.

For a model without a .team foreign key (ProductTeamModel), read organization_id from Team on the main database inside the receiver.

Step 4 - Wire it

  • In products/<name>/backend/apps.py ready(): from products.<name>.backend import activity_logging # noqa: F401, PLC0415, with a one-line comment that says why it must connect in every process.
  • Add model_activity:products.<name>.backend.activity_logging.<handler> to posthog/test/repo_invariants/setup_receivers_baseline.txt.

A receiver that is not imported in ready() connects only where something else imports the module. That is the silent failure this convention exists to prevent.

Step 5 - Bulk writes

For each bulk write from step 1:

  • Read the before-values from the writer database before the update.
  • Run the update.
  • Build one Change per field that actually changed, for rows whose value changed.
  • Call bulk_log_activity (or log_activity for one row) with user=None when no request user exists, and a Trigger that names the job and its id.

Do not wrap a request path in mute_selected_signals(). The flag is process-wide.

Show full SKILL.md (262 more words)Show less

Step 6 - Separate-database products only

When the model is routed in products/db_routing.yaml:

  • Pass using=router.db_for_write(Thing) to every log_activity and bulk_log_activity call in the product, including the receiver. Without it, the audit row is written before the product row commits and survives its rollback.
  • The mixin already pins its before-update read to the writer and reads by primary key without a team filter.

Step 7 - Tune the diff

  • Fields a job touches on every run go in signal_exclusions (no row is logged when only they change).
  • Bookkeeping fields go in field_exclusions (dropped from the diff).
  • Secrets go in field_with_masked_contents (the change is recorded, the values are not).
  • User-facing names go in field_name_overrides.

Step 8 - Describer (optional)

defaultDescriber renders "X created / updated / deleted <name>". Write products/<name>/frontend/activityDescriber.tsx and register it in frontend/src/lib/components/ActivityLog/describers.tsx when the default text does not say what changed in the user's words. Invoke /writing-user-facing-copy before you write the strings.

Step 9 - Tests

Invoke /writing-tests first. Add the tests listed under Tests in the doc, and no more.

Verify

sh
hogli test products/<name>/backend/tests/<file>.py
hogli test posthog/test/repo_invariants/test_startup_import_budget.py
ruff check products/<name>/backend/activity_logging.py posthog/models/activity_logging --fix

Then check the row in a shell: ActivityLog.objects.filter(scope="Thing").order_by("-created_at").first().detail.

Debugging a missing row

Work down this list; each item is a distinct cause.

  1. The receiver module is not imported in ready() (check setup_receivers_baseline.txt for the handler name).
  2. The write bypassed save() (step 1).
  3. Only excluded fields changed (signal_exclusions), or the diff was empty and force_save was not set.
  4. ACTIVITY_LOG_TRANSACTION_MANAGEMENT deferred the write to a commit that never came, or to the wrong connection (step 6).
  5. The row exists but the reader is outside the entitlement's lookback window, or activity_visibility_restrictions hides it.

© PostHog, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in .agents/skills/adding-activity-logging of PostHog/posthog-foss.

Open the folder on GitHubat commit 2c48221

Compare with similar skills

Adding Activity Logging next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Adding Activity Logging compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Adding Activity Logging this skillPostHog/posthog-foss721—~1.5kAutomated safety check: PassMIT
Saleor Django Schema Migrationsaleor/saleor23k—~1kAutomated safety check: PassBSD-3-Clause
Django Access Reviewgetsentry/skills1k3 repos~2.6kAutomated safety check: NotesApache-2.0
Silk Profilerbaserow/baserow6.1k—~2.9kAutomated safety check: PassCustom licence
Arch Wikiahmedemad3/arch-wiki249—~5.1kAutomated safety check: PassNone
Run Testsnetboxlabs/netbox-branching155—~1.2kAutomated safety check: PassCustom licence

Similar skills

  • Generates and splits Django schema migrations for Saleor with manage.py makemigrations, enforcing one new model or one field change per migration file.

    23k GitHub stars~1k tokensUpdated today
    Backend & APIsAuto-check passed
  • Django Access Review

    getsentry/skills

    Official

    Django access control and IDOR security review. An agent skill from getsentry/skills.

    1k GitHub starsUsed in 3 repos~2.6k tokens
    Backend & APIsAuto-check: notes
  • Silk Profiler

    baserow/baserow

    Investigate backend performance using Django Silk profiling data.

    6.1k GitHub stars~2.9k tokensUpdated today
    Backend & APIsAuto-check passed
  • Arch Wiki

    ahmedemad3/arch-wiki

    Scans any project codebase for new/changed modules, endpoints, middleware, infrastructure, Docker topologies, SQL queries, or permissions and updates docs/architecture/architecture.json.

    249 GitHub stars~5.1k tokensUpdated 18 days ago
    Backend & APIsAuto-check passed
  • Run Tests

    netboxlabs/netbox-branching

    Run the netboxbranching plugin's Django test suite against a local NetBox checkout.

    155 GitHub stars~1.2k tokensUpdated today
    Backend & APIsAuto-check passed
  • Add or change a CLIST Django management command, including arguments, resource selection, EventLog monitoring, or cron and Healthchecks wiring.

    439 GitHub stars~848 tokensUpdated 2 days ago
    Backend & APIsAuto-check passed

More from PostHog/posthog-foss

All 213 skills in this repo
  • Authoring Log Alerts

    PostHog/posthog-foss

    Official

    Author useful, low-noise log alerts on services in a PostHog project.

    721 GitHub stars~3k tokensUpdated today
    Auto-check passed
  • Autoresolving PR Conflicts

    PostHog/posthog-foss

    Official

    Operating procedure for the conflict-autoresolver agent: sweep open PostHog/posthog PRs that conflict with master, resolve the trivial conflicts (generated artifacts deterministically, source…

    721 GitHub stars~4.2k tokensUpdated today
    Auto-check passed
  • Official

    Help users debug PostHog Error Tracking stack-trace symbolication for any supported platform — JavaScript/TypeScript web, React Native (Hermes), Android (Proguard / R8), or iOS / macOS (dSYM).

    721 GitHub stars~2.2k tokensUpdated today
    Auto-check passed
  • Exploring Apm Traces

    PostHog/posthog-foss

    Official

    Investigates distributed application performance using PostHog APM (OpenTelemetry span) data via MCP.

    721 GitHub stars~3.5k tokensUpdated today
    Auto-check passed
  • Exploring LLM Traces

    PostHog/posthog-foss

    Official

    Debug and inspect LLM/AI agent traces using PostHog's MCP tools.

    721 GitHub stars~4.4k tokensUpdated today
    Auto-check passed
  • Investigate Metric

    PostHog/posthog-foss

    Official

    Diagnose why a product metric changed (dropped, spiked, or plateaued) by orchestrating breakdowns, actors, paths, lifecycle, retention, and annotations queries.

    721 GitHub stars~1.9k tokensUpdated today
    Auto-check passed

Works with

Categories

Questions about Adding Activity Logging

What does Adding Activity Logging do?

Adds or changes activity logging (the audit trail) for a Django model in PostHog. Adding Activity Logging is an agent skill from PostHog/posthog-foss, published by the product's own GitHub organization. Adds or changes activity logging (the audit trail) for a Django model in PostHog.

When should I use Adding Activity Logging?

Adding Activity Logging fits situations like: A models writes must show in the Activity side panel; the advanced activity logs; adding ModelActivityMixin; an ActivityScope.

How do I install Adding Activity Logging in Claude Code?

Run `npx skills add PostHog/posthog-foss --skill adding-activity-logging -a claude-code`. Or copy the skill folder (.agents/skills/adding-activity-logging in PostHog/posthog-foss) into .claude/skills/adding-activity-logging in your project. Claude Code loads it when a task matches its description.

How do I install Adding Activity Logging in Codex?

Run `npx skills add PostHog/posthog-foss --skill adding-activity-logging -a codex`. Or copy the skill folder (.agents/skills/adding-activity-logging in PostHog/posthog-foss) into .agents/skills/adding-activity-logging in your project. Codex loads it when a task matches its description.

Can I use Adding Activity Logging in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add PostHog/posthog-foss --skill adding-activity-logging -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/adding-activity-logging, .gemini/skills/adding-activity-logging, .github/skills/adding-activity-logging and .opencode/skills/adding-activity-logging in your project.

What does Adding Activity Logging need to run?

Going by SKILL.md and its folder, Adding Activity Logging needs the command-line tools its instructions call (rg and ruff).

Does Adding Activity Logging access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Adding Activity Logging safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Adding Activity Logging use?

Adding Activity Logging is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Adding Activity Logging use?

About 1.5k tokens (SKILL.md is roughly 6.2k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Adding Activity Logging?

Skills that share tags, products or a category with Adding Activity Logging: Saleor Django Schema Migration (saleor/saleor, 23k stars), Django Access Review (getsentry/skills, 1k stars), Silk Profiler (baserow/baserow, 6.1k stars) and Arch Wiki (ahmedemad3/arch-wiki, 249 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Adding Activity Logging?

PostHog (a GitHub organization, an official publisher) maintains it in PostHog/posthog-foss, which has 721 GitHub stars. The repository holds 213 skills in this directory. The repository was last updated on October 7, 2026.

Source: PostHog/posthog-foss on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.