CLI + Skill · version 1.0
Plausible Automation Toolkit
A macOS CLI and Codex skill for self-hosted Plausible Community Edition. Configure your own analytics origin, create website properties, install trackers, report traffic, and manage goals without putting credentials in projects or AI chats.
Why I built this
Adding Plausible to a site is small enough to do manually and repetitive enough to keep doing badly. The real workflow is more than one script tag: create the property, select the correct shared layout, avoid duplicate analytics, store the login safely, generate a reporting key, remember the Stats query shape, and configure goals later.
I built one local tool that handles that whole lifecycle. The deterministic CLI does the fragile work and the Codex skill supplies project-aware judgment: preview the edit, inspect the result, run the site checks, and turn a request like “install Plausible on this site” into a repeatable operation.
From project folder to useful analytics
Configure once. Operate every website with the same guarded workflow.
- Set your own Plausible origin.
- Create the property and install its tracker.
- Query traffic through the Stats API.
- Manage site-scoped conversion goals.
Features
Your Plausible domain
Configure the HTTPS origin of the self-hosted instance you own. No vendor or seller domain is baked in.
Per-project domain discovery
Infer each website from Astro site metadata, package homepage, or the project directory, with explicit overrides.
Property provisioning
Sign in through the live Community Edition dashboard and create the property idempotently without the Sites API.
Safe tracker insertion
Find the shared head, show a unified diff, preserve Astro inline behavior, and refuse duplicate analytics.
Traffic reports
Query visitors, visits, pageviews, bounce rate, visit duration, top pages, sources, and goals with previous-period changes.
Breakdowns and exports
Analyze countries, devices, campaigns, pages, goals, sources, and custom properties as text, JSON, CSV, or Markdown.
Read-only doctor
Check the instance, tracker endpoint, project snippet, property, Stats key, and optional Plugins API without changing them.
Goal management
List and create custom-event or pageview goals, and delete one exact goal only with explicit confirmation.
Separated Keychain secrets
Keep dashboard login, generated Stats key, and every site plugin token in distinct macOS Keychain items.
Natural-language operation
Install the included Codex skill and ask for Plausible installation, traffic summaries, or goal changes.
Tested local core
Run eight fake-server regression tests without contacting a real instance, website, or Keychain.
Use cases
Install analytics repeatedly
Use the same guarded workflow across an Astro portfolio, static landing pages, and client projects.
Ask for weekly traffic
Let Codex run a read-only report and explain the important pages, sources, and conversions in plain language.
Standardize launch checklists
Add property creation, tracker verification, and initial goals to a repeatable pre-launch workflow.
Operate several websites
Keep one configured Plausible instance while resolving and authenticating every tracked domain separately.
Learn reliable dashboard automation
Study CSRF-aware forms, cookie sessions, state verification, and fail-closed handling in plain Python.
Build a broader analytics operator
Add campaign, geography, device, comparison, export, health-check, or scheduled-report workflows.
Tech stack
Portable CLI core
Python 3
Uses the standard library for argument parsing, HTTP, cookie sessions, HTML forms, JSON, diffs, and project inspection.
Natural-language interface
Codex skill
Triggers on installation, traffic, and goal requests and guides the agent through previews, checks, and secret-safe handoffs.
Secret storage
macOS Keychain
Stores three credential classes under origin- and site-scoped service names without plaintext config files.
Community Edition setup
Plausible dashboard
Creates properties and Stats keys through authenticated, CSRF-aware form submissions with state verification.
Read-only analytics
Stats API v2
Supplies summary metrics, content, acquisition, and conversion data for text or JSON reports.
Site-scoped goals
Plugins API
Lists and changes custom-event and pageview goals through a token limited to one tracked website.
CLI
The included command is useful by itself and is also the deterministic execution layer behind the Codex skill. Every account-specific value is supplied by you or inferred from the current project.
plausible-setup configure --plausible-url https://plausible.example.comSave the HTTPS origin of your own self-hosted Plausible instance.
plausible-setup credentialsStore the dashboard login through an interactive macOS Keychain prompt.
plausible-setup setup --dry-runResolve the website domain and shared layout, then preview property and tracker work.
plausible-setup setup --domain example.comCreate or find the property and install the matching tracker for one explicit website.
plausible-setup doctor --domain example.comRun independent read-only checks across local setup and remote Plausible services.
plausible-setup report --domain example.com --period 30d --compare previousReport important metrics and explain changes from the immediately preceding period.
plausible-setup breakdown --domain example.com --by country --format markdownBreak traffic down by a supported dimension and export a presentation-ready table.
plausible-setup goal-add --domain example.com --event SignupCreate or find a custom-event goal through the site-scoped Plugins API.
Usage manual
Run it and make it yours.
The setup and usage guide from the ZIP. Read it before downloading so you know what the software needs.
Plausible Automation Toolkit is a macOS command-line tool and Codex skill for operating a self-hosted Plausible Community Edition instance. It can create a website property through the authenticated dashboard, install the tracking script in a project, produce traffic reports, and manage goals.
You supplies both values that identify their setup:
- the HTTPS origin of their own Plausible instance;
- the public domain of each website they operate.
No seller-owned domain, login, API key, plugin token, or analytics data is in this package.
Current release: 1.0.0.
Requirements
- macOS with the
securityandexpectcommands - Python 3.10 or newer
- a self-hosted Plausible Community Edition account
- a website project with one shared file containing
</head> - Codex if you want natural-language skill triggering; the CLI works directly
The included implementation is intentionally macOS-first because all secrets are stored in login Keychain.
Install
Extract the download, open Terminal, and run:
cd 30-plausible-automation/code
./install.sh --plausible-url https://plausible.example.com
Replace the example URL with the HTTPS origin of your own Plausible instance.
The installer copies the skill to ~/.codex/skills/setup-plausible and the CLI
to ~/.local/bin/plausible-setup.
If ~/.local/bin is not on PATH, add this to ~/.zshrc:
export PATH="$HOME/.local/bin:$PATH"
Then open a new Terminal window.
First run
Store the Plausible dashboard login in Keychain:
plausible-setup credentials
From a website project, preview and apply the integration:
plausible-setup setup --dry-run
plausible-setup setup
The CLI infers the tracked domain from Astro's site, package.json's
homepage, or a dotted project-directory name. Override it whenever needed:
plausible-setup setup --domain shop.example.com --target src/layouts/Layout.astro
Health, reports, and goals
plausible-setup doctor --domain example.com
plausible-setup report --domain example.com --period 7d
plausible-setup report --domain example.com --period 30d --compare previous
plausible-setup breakdown --domain example.com --period 30d --by country
plausible-setup breakdown --domain example.com --by page --filter source=Google
plausible-setup report --domain example.com --format markdown
plausible-setup goals-list --domain example.com
plausible-setup goal-add --domain example.com --event Signup
plausible-setup goal-add --domain example.com --page '/thank-you*'
doctor checks the instance, tracker endpoint, project snippet, property,
Stats API, and optional goal token without changing anything. Reports support
text, JSON, CSV, and Markdown output. The first report creates a Stats API key through the authenticated dashboard
and saves it in Keychain. Goal commands require one site-scoped plugin token;
the CLI prints the exact dashboard URL and stores the resulting token through a
secure Terminal prompt.
Codex use
After installation, ask Codex things like:
- “Install Plausible on this site.”
- “Show me Plausible traffic for the last 30 days.”
- “Add a Signup goal in Plausible.”
The skill tells Codex to inspect changes, keep secrets out of chat, preview tracker edits, and avoid Plausible's Sites API.
Verify the package
cd code
python3 -m unittest discover -s tests -v
python3 setup-plausible/scripts/plausible-setup --version
The eight tests use a local fake server. They do not contact Plausible, change a real site, or read you's Keychain.
Documentation
CONFIGURATION.md— instances, domains, Keychain services, and overridesSECURITY.md— secret handling and mutation boundariesARCHITECTURE.md— dashboard, Stats API, Plugins API, and project flowsCUSTOMIZATION.md— extensions and portability seamsDEPLOYMENT.md— installation, upgrades, and removalBUILDING.md— verification and release processAGENTS.md— invariants for AI coding agents
License
MIT. Keep the included license notice with substantial copies.
Architecture
See how the software is put together.
Review the system flow, boundaries, integrations, and replaceable parts before you download it.
Overview
The toolkit has two entry points over one implementation:
flowchart TD
developer["Developer / terminal"] --> cli["plausible-setup CLI"]
request["Codex request"] --> skill["setup-plausible skill"] --> cli
cli --> doctor["Doctor checks"]
cli --> dashboard["Dashboard session"] --> property["Property + Stats key"]
cli --> stats["Stats API v2"] --> reports["Traffic reports"]
cli --> plugins["Plugins API"] --> goals["Goals"]
cli --> tracker["Project tracker edit"]
config["Config<br/>~/.config/plausible-setup/config.json"] -. settings .-> cli
keychain["Secrets<br/>separate macOS Keychain items"] -. credentials .-> cli
classDef entry fill:#332d23,stroke:#e8a830,stroke-width:2px,color:#f0e4cc
classDef core fill:#c85520,stroke:#e8a830,stroke-width:2px,color:#fff8ea
classDef service fill:#2d2a25,stroke:#a87628,color:#f0e4cc
classDef output fill:#211f1c,stroke:#5b5143,color:#d2c4aa
classDef storage fill:#25231f,stroke:#7c6b50,stroke-dasharray:5 4,color:#d2c4aa
class developer,request,skill entry
class cli core
class doctor,dashboard,stats,plugins service
class property,reports,goals,tracker output
class config,keychain storage
Codex loads setup-plausible/SKILL.md when a request concerns installation,
traffic reporting, or goals. The skill delegates deterministic work to the
bundled CLI.
Configuration and identity
The Plausible origin is selected in this order:
--plausible-urlfor one invocation;PLAUSIBLE_URLfor one process environment;- the value saved by
plausible-setup configure.
The tracked domain is selected independently from --domain, Astro's site,
package.json's homepage, or the project directory name. This separation is
what allows one CLI installation to operate many websites on one Plausible
instance.
Dashboard flow
Property creation and Stats key generation use an authenticated cookie session. The CLI fetches the current HTML forms, preserves hidden inputs including CSRF tokens, submits the documented dashboard fields, follows redirects, and checks the resulting state. It does not use the Sites API.
Tracker flow
The CLI finds a shared layout or HTML file containing a standalone </head>,
builds a script tag from the configured origin and resolved website domain,
and produces a unified diff. It refuses ambiguous layouts and existing
analytics snippets instead of guessing.
Reporting flow
The first report creates a Stats API key and hands the generated value directly
to the Keychain helper over standard input. Reports query Stats API v2 for the
summary, top pages, top sources, and goal conversions. Output can be human
readable, JSON, CSV, or Markdown. Comparison reports calculate the immediately
preceding calendar range locally and query both periods. Breakdowns map stable
CLI aliases to Stats API dimensions and translate repeatable NAME=VALUE
filters into structured API filters.
Diagnostic flow
doctor performs independent read-only checks and retains every result instead
of stopping at the first problem. Missing optional keys are warnings; instance,
tracker, property, project-snippet, or API failures make the command non-zero.
Goal flow
Each website has its own Plugins API token. The CLI authenticates with the
tracked domain and token, then lists, creates, or deletes custom-event and
pageview goals. Deletion requires both an exact numeric ID and --yes.
What’s included
- Plausible Automation Toolkit version 1.0.0 with complete MIT-licensed source
- Developer-configurable self-hosted Plausible origin with CLI, environment, and saved-config precedence
- Per-project tracked-domain inference plus explicit domain and target overrides
- Dashboard property provisioning with current hidden-field and CSRF token preservation
- Dry-run tracker diffs, Astro-aware script insertion, and duplicate-integration refusal
- Automatic Stats API key generation and rotation without exposing the generated secret
- Read-only doctor checks for the Plausible origin, tracker, project snippet, property, Stats API, and Plugins API
- Reports with summary, top pages, sources, goals, previous-period changes, and text, JSON, CSV, or Markdown output
- Filtered breakdowns by geography, acquisition, technology, content, goals, and custom properties
- Custom-event and pageview goal list, create, and confirmation-gated delete commands
- Separate macOS Keychain identities for login, reporting, and each website plugin token
- Installable Codex skill with tested trigger phrases and conservative operating instructions
- One-command local installer plus eight regression tests using a fake Plausible server
- Setup, architecture, security, configuration, customization, deployment, build, decision, agent, and release documentation
- MIT license, generated package manifest, audited ZIP, and SHA-256 checksum
Documentation
The ZIP includes project context for you and your coding agents.
README.md
The starting point: what the software does, prerequisites, local setup, commands, and the shortest path to a working copy.
CHANGELOG.md
The release history and the public changes included in each version.
BUILDING.md
The build story: how the software was made, the difficult parts, how it was verified, and what could come next.
AGENTS.md
Project context and operating rules for Codex, Claude Code, Cursor, and other AI coding agents.
ARCHITECTURE.md
How the major parts fit together, where data flows, and where to make structural changes.
DECISIONS.md
The main technical and product choices, including tradeoffs worth preserving or revisiting.
CUSTOMIZATION.md
A practical map for changing the brand, interface, features, data model, and integrations.
DEPLOYMENT.md
A production checklist covering resources, environment setup, builds, and deployment verification.
CONFIGURATION.md
Every setting and environment variable, where it is used, and how to configure local and production environments.
SECURITY.md
Credential handling, trust boundaries, sensitive data, and checks to run before publishing your version.
Why download this
- Stop rebuilding the same setup script and dashboard checklist for every website
- Keep analytics credentials out of repositories, shell history, and AI conversations
- Start with real property, report, and goal workflows instead of a script-tag snippet
- Give Codex a focused, deterministic tool instead of broad browser access
- Own a small standard-library codebase that is straightforward to inspect and extend
- Reuse or resell a derivative under the permissive MIT license
Customize it
Use the working source as a foundation. Keep it small, change it for your own workflow, or turn it into a different product.
- Add framework-specific domain and shared-layout discovery for the stack you use most.
- Build previous-period comparisons and have your agent explain meaningful traffic changes.
- Export CSV or Markdown reports for newsletters, client updates, or project journals.
- Add country, device, campaign, entry-page, and exit-page sections through Stats API v2.
- Port secret storage to Linux Secret Service or Windows Credential Manager behind the documented seam.
- Turn it into a scheduled analytics operator with health checks, alerts, and weekly summaries.
MIT license
Every source ZIP includes an MIT LICENSE file. You can use, copy, change, publish, distribute, sublicense, or sell the code, including as part of a commercial product.
Keep the copyright and license notice with copies or substantial portions of the code. Third-party dependencies and assets keep their own licenses.
Keep learning
Ship Factory
See how a focused CLI and Codex skill turn a repeated operational job into an agent-ready workflow.
