mixpanel-headless
Copilot instructions18 starsChanged 7 months agoMITView on GitHub
Python library + CLI for Mixpanel analytics: discovery, live queries, streaming, and entity management. CLAUDE.md at the repo root is the source of truth for conventions, architecture, and environment variables. This file is a short summary; where they disagree, CLAUDE.md wins. Layer rules: - CLI never imports or constructs MixpanelAPIClient; API calls go through Workspace. CLI modules may use _internal config, auth, and helper modules (e.g., ConfigManager, the session resolver). - Services call infrastructure only (no horizontal service calls) See…
In this repository17 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- mutation-testingSkill
- skill-creatorSkill
- speckit-analyzeSkill
- speckit-checklistSkill
- speckit-clarifySkill
- speckit-constitutionSkill
- speckit-git-commitSkill
- speckit-git-featureSkill
- speckit-git-initializeSkill
- speckit-git-remoteSkill
- speckit-git-validateSkill
- speckit-implementSkill
- speckit-planSkill
- speckit-specifySkill
- speckit-tasksSkill
- speckit-taskstoissuesSkill
The file
Show its rules and text
We split this copilot-instructions.md into the rules it gives an agent
20 rules. About 0 are common, 5 are distinctive, and 15 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈5
Distinctive · estimate
This author's own choices. Worth a look.
15
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 79
All code passes mypy --strict
- Very specific: line 81
Use X | None (not Optional[X])
- Very specific: line 82
Use Literal for constrained strings
- Very specific: line 85
Every class, method, and function has a docstring, including private helpers and tests (checked by interrogate in CI: every definition in …
- Distinctive: line 96
Write test FIRST, then implement
- Very specific: line 105
Use Iterator[T] not list[T] for streaming data
- Very specific: line 106
Use field(default_factory=list) not [] for defaults
- Very specific: line 110
Use the library hierarchy in exceptions.py, never bare Exception.
- Distinctive: line 124
Don't interpolate secrets in f-strings
- Very specific: line 125
Don't log accounts, sessions, or tokens in a way that bypasses their redacting __repr__
- Very specific: line 140
Check context/ for design specs
- Very specific: line 141
Write test in tests/unit/ first
- Very specific: line 143
Run all checks: just check
- Distinctive: line 146
Write failing test reproducing bug
- Distinctive: line 153
Follow existing patterns (formatters, error handling)
- Very specific: line 157
Update __init__.py exports if needed
- Very specific: line 158
Never expose _internal types in signatures
- Very specific: line 163
Use except Exception: (use MixpanelHeadlessError)
- Very specific: line 164
Use mutable defaults (list → field(default_factory=list))
- Distinctive: line 167
Commit without running all checks
≈ “Common” is an estimate: at least 1 in 5 of the 1,644 Copilot instructions files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Copilot Instructions for mixpanel_headless
Python library + CLI for Mixpanel analytics: discovery, live queries, streaming, and entity management.
CLAUDE.md at the repo root is the source of truth for conventions, architecture, and environment variables. This file is a short summary; where they disagree, CLAUDE.md wins.
Quick Reference (Start Here)
# Setup (REQUIRED first)
uv sync --all-extras
# Verify changes — `just check` runs everything below plus docstring coverage and the build
just check
# Or individually
uv run ruff format src/ tests/ # Format code
uv run ruff check src/ tests/ # Lint code
uv run mypy src/ tests/ # Type check
uv run pytest # Run tests
# Run specific test
uv run pytest -k test_name
# Tests with coverage (must be ≥90%)
uv run pytest --cov=src/mixpanel_headless --cov-fail-under=90Tech Stack
- Language: Python 3.10+
- CLI: Typer + Rich
- Validation: Pydantic v2
- HTTP: httpx
- Testing: pytest, Hypothesis, mutmut, ruff, mypy, interrogate
Project Structure
src/mixpanel_headless/
├── workspace.py # Workspace facade (entry point for library)
├── auth_types.py # Public auth surface (Account union, Session, Region, OAuthTokens, …)
├── accounts.py # mp.accounts — add/list/use/login/test/…
├── session.py # mp.session — show/use the persisted [active] block
├── targets.py # mp.targets — saved (account, project, workspace?) cursors
├── exceptions.py # Exception hierarchy
├── types.py # Result types (frozen dataclasses)
├── reference.py # Built-in API help (mp.help)
├── _internal/ # PRIVATE: never expose in public signatures
│ ├── config.py # ConfigManager (TOML-backed)
│ ├── api_client.py # MixpanelAPIClient
│ ├── auth/ # Account types, session resolver, OAuth flow, bridge file
│ ├── query/ # Query builders and validators
│ ├── replays/ # Session-replay analyzer (vendored rrweb)
│ └── services/ # Discovery, LiveQuery, Replays services
└── cli/
├── main.py # Typer entry point + global flags (-a / -p / -w / -t)
└── commands/ # account, project, workspace, target, session, query, inspect, entity CRUD, …
tests/
├── unit/ # Isolated tests (mocked deps)
├── integration/ # Component interaction tests
└── pbt/ # Property-based tests (Hypothesis)Architecture
CLI (Typer) → Public API (Workspace) → Services → Infrastructure (Config, API)Layer rules:
- CLI never imports or constructs
MixpanelAPIClient; API calls go throughWorkspace. CLI modules may use_internalconfig, auth, and helper modules (e.g.,ConfigManager, the session resolver). - Services call infrastructure only (no horizontal service calls)
Code Requirements
Types (STRICT)
- All code passes
mypy --strict - No
Anywithout justification - Use
X | None(notOptional[X]) - Use
Literalfor constrained strings
Docstrings (REQUIRED)
Every class, method, and function has a docstring, including private helpers and tests (checked by interrogate in CI: every definition in src/ and conformance/, 95% of tests/). Sections depend on the function (Google style):
- Summary: always
- Args: when it takes parameters (no types — those are in the annotations)
- Returns: when it returns a non-
Nonevalue - Raises: exceptions it raises deliberately
- Example: where behavior isn't obvious; use fenced code blocks, not
>>> - Tests and fixtures: a one-line summary of what the test proves, matching the file's convention
See the "Documentation (STRICT)" section of CLAUDE.md for the full rule.
Testing (TDD)
- Write test FIRST, then implement
- Unit tests:
tests/unit/ - Integration tests:
tests/integration/ - Property-based tests:
*_pbt.py - Coverage minimum: 90%
Patterns
frozen=Trueon all dataclassesmodel_config = ConfigDict(frozen=True)on Pydantic models- Use
Iterator[T]notlist[T]for streaming data - Use
field(default_factory=list)not[]for defaults
Exceptions
Use the library hierarchy in exceptions.py, never bare Exception. Common classes:
MixpanelHeadlessError(base)ConfigError→AccountNotFoundError,AccountExistsError,AccountInUseError,ProjectNotFoundError,InvalidArgumentErrorAPIError→AuthenticationError,RateLimitError,QueryError,ServerError,SessionReplayErrorOAuthError→RegionProbeErrorWorkspaceScopeError,ParamValidationError,BookmarkValidationError,ReportLinkError,HelpLookupError
Always chain: raise XError(...) from e
Security: Credentials
NEVER expose secrets:
- Account secrets and tokens are
SecretStr; call.get_secret_value()only where the raw value is sent - Don't interpolate secrets in f-strings
- Don't log accounts, sessions, or tokens in a way that bypasses their redacting
__repr__
Configuration
- Config file (TOML):
~/.mp/config.toml(override withMP_CONFIG_PATH) - Multiple named accounts (
service_account,oauth_browser,oauth_token) with an[active]session block - Environment variables override config (full table in
CLAUDE.md):MP_USERNAME+MP_SECRET(service account) orMP_OAUTH_TOKEN(static bearer)MP_PROJECT_ID,MP_REGION,MP_WORKSPACE_IDMP_AUTH_FILE,MP_CONFIG_PATHMP_API_BASE_URL,MP_APP_BASE_URL
Agent Task Guidelines
Adding a Feature
- Check
context/for design specs - Write test in
tests/unit/first - Implement minimal code to pass
- Run all checks:
just check
Fixing a Bug
- Write failing test reproducing bug
- Fix implementation
- Run all checks:
just check
Adding CLI Command
- Add to
src/mixpanel_headless/cli/commands/ - Register in
main.py - Follow existing patterns (formatters, error handling)
Modifying Public API
- Edit
workspace.pyorauth_types.py - Update
__init__.pyexports if needed - Never expose
_internaltypes in signatures
DO NOT
- Expose
_internaltypes in public signatures - Use
except Exception:(useMixpanelHeadlessError) - Use mutable defaults (
list→field(default_factory=list)) - Skip type annotations
- Skip docstrings
- Commit without running all checks
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

