Skip to content

Repository files navigation

Important

PostHog Code is pre-alpha and not production-ready. Interested? Email jonathan@posthog.com

Download the latest version

Found a bug or have feedback? Open an issue on GitHub.

PostHog Code

This is the monorepo for PostHog Code apps and the agent framework that powers them.

Development

Prerequisites

  • Node.js 22+
  • pnpm 10.23.0

Setup

# Install pnpm if you haven't already
npm install -g pnpm
# Install dependencies for all packages
pnpm install
# Copy environment config
cp .env.example .env

Running in Development

# Run both agent (watch mode) and code app in parallel
pnpm dev
# Or run them separately:
pnpm dev:agent # Run agent in watch mode
pnpm dev:code # Run code app

Want to connect to a local PostHog instance? See docs/LOCAL-DEVELOPMENT.md for OAuth setup and connecting to localhost:8010.

Utility Scripts

Scripts in scripts/ for development and debugging:

ScriptDescription
scripts/clean-posthog-code-macos.shRemove all PostHog Code app data from macOS (caches, preferences, logs, saved state). Use --app flag to also delete PostHog Code.app from /Applications.
scripts/test-access-token.jsValidate a PostHog OAuth access token by testing API endpoints. Usage: node scripts/test-access-token.js <token> <project_id> [region]

Project Structure

posthog-code/
├── apps/
│ ├── code/ # Electron desktop app (React, Vite)
│ ├── mobile/ # React Native mobile app (Expo)
│ └── cli/ # CLI for stacked PRs
├── packages/
│ ├── agent/ # TypeScript agent framework
│ ├── core/ # Shared business logic
│ ├── electron-trpc/ # tRPC for Electron IPC
│ └── shared/ # Shared utilities (Saga pattern, etc.)

Documentation

FileDescription
apps/code/README.mdDesktop app: building, signing, distribution, and workspace configuration
apps/code/ARCHITECTURE.mdDesktop app: dependency injection, tRPC, state management, and events
apps/mobile/README.mdMobile app: Expo setup, EAS builds, and TestFlight deployment
apps/cli/README.mdCLI: stacked PR management with Jujutsu
CLAUDE.mdCode style, patterns, and testing guidelines
docs/LOCAL-DEVELOPMENT.mdConnecting PostHog Code to a local PostHog instance
docs/UPDATES.mdRelease versioning and git tagging
docs/TROUBLESHOOTING.mdCommon issues and fixes

Troubleshooting

See docs/TROUBLESHOOTING.md for common issues (black screen, Electron install failures, native module crashes, etc.).

About

The Agentic Development Environment

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages