https://github.com/posthog/code
The era of self-driving development is here
https://github.com/posthog/code
Last synced: 19 days ago
JSON representation
The era of self-driving development is here
- Host: GitHub
- URL: https://github.com/posthog/code
- Owner: PostHog
- License: mit
- Created: 2025-09-25T21:53:50.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2026-06-13T12:34:27.000Z (21 days ago)
- Last Synced: 2026-06-13T14:13:36.211Z (21 days ago)
- Language: TypeScript
- Homepage: https://posthog.com/code
- Size: 170 MB
- Stars: 137
- Watchers: 0
- Forks: 37
- Open Issues: 229
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Agents: AGENTS.md
Awesome Lists containing this project
README
> [!IMPORTANT]
> Interested in PostHog Code? [Join the waitlist](https://posthog.com/code) or hop into our [Discord](https://discord.gg/aSrHKVNVdR).
**[Download the latest version](https://github.com/PostHog/code/releases/latest)**
Found a bug or have feedback? [Open an issue](https://github.com/PostHog/code/issues/new) 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
```bash
# Install pnpm if you haven't already
npm install -g pnpm
# Install dependencies for all packages
pnpm install
# Optional: copy environment config
# Only needed for code signing (APPLE_*) or PostHog analytics (VITE_POSTHOG_*).
# The app runs fine in dev without it.
cp .env.example .env
```
### Running in Development
By default, `pnpm dev` uses phrocs (our custom process runner) to run the agent and code app in parallel. phrocs auto-installs on first run and reads the `mprocs.yaml` config file. The binary is downloaded to `bin/phrocs` and is git-ignored.
```bash
# 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
# Manually update phrocs to the latest version
pnpm update:phrocs
# Use mprocs instead of phrocs
pnpm dev:mprocs
```
> **Want to connect to a local PostHog instance?** See [docs/LOCAL-DEVELOPMENT.md](./docs/LOCAL-DEVELOPMENT.md) for OAuth setup and connecting to localhost:8010.
### Utility Scripts
Scripts in `scripts/` for development and debugging:
| Script | Description |
|--------|-------------|
| `scripts/clean-posthog-code-macos.sh` | Remove 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.js` | Validate a PostHog OAuth access token by testing API endpoints. Usage: `node scripts/test-access-token.js [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
| File | Description |
|------|-------------|
| [apps/code/README.md](./apps/code/README.md) | Desktop app: building, signing, distribution, and workspace configuration |
| [apps/mobile/README.md](./apps/mobile/README.md) | Mobile app: Expo setup, EAS builds, and TestFlight deployment |
| [apps/cli/README.md](./apps/cli/README.md) | CLI: stacked PR management with Jujutsu |
| [AGENTS.md](./AGENTS.md) | Architecture rules, code style, patterns, and testing guidelines (read by Claude Code, Codex, Cursor, Aider, etc.) |
| [CONTRIBUTING.md](./CONTRIBUTING.md) | How to contribute to PostHog Code |
| [docs/LOCAL-DEVELOPMENT.md](./docs/LOCAL-DEVELOPMENT.md) | Connecting PostHog Code to a local PostHog instance |
| [docs/UPDATES.md](./docs/UPDATES.md) | Release versioning and git tagging |
| [docs/TROUBLESHOOTING.md](./docs/TROUBLESHOOTING.md) | Common issues and fixes |
| [docs/DEEP-LINKS.md](./docs/DEEP-LINKS.md) | `posthog-code://` deep link schemes and parameters |
## Contributing
We love contributions big and small. See [CONTRIBUTING.md](./CONTRIBUTING.md) to get started.
## Troubleshooting
See [docs/TROUBLESHOOTING.md](./docs/TROUBLESHOOTING.md) for common issues (black screen, Electron install failures, native module crashes, etc.).