# The smallest permission model for a founder's AI agent

> Exact, copy-pasteable least-privilege token scopes for GitHub, Stripe restricted keys, PostHog, Sentry, Slack, and Postgres so a prompt-injected AI agent cannot drain accounts or delete production data.

By Founder2 Editorial, The Founder2 journal. Published 2026-11-22. Topic: AI co-founder. Canonical: https://tryfounder2.com/blog/smallest-permission-model-founder-agent

## Key takeaways

- Never hand an AI agent a personal access token (classic PAT), a Stripe secret key (sk_live_), or a Postgres superuser string; every integration has a narrow, revocable alternative.
- Split GitHub permissions into two tokens or a scoped GitHub App: read-only metadata/issues/PRs for analysis, and gated issue/branch writes only when approved.
- Use Stripe restricted keys (rk_live_) with Read access strictly on Customers, Subscriptions, Invoices, and Charges, and Write set to None across everything.
- Keep raw secrets outside the agent sandbox in a credential broker so even a prompt-injected session cannot read or exfiltrate your API keys.

The smallest safe permission model for a founder's AI agent gives **read-only, single-project or single-repository scopes** everywhere by default, isolates raw credentials inside an external broker instead of VM environment variables, and grants write access solely to reversible or human-approved endpoints like GitHub issues or feature branches. Every vendor already ships fine-grained scopes; the gap is that most setup tutorials still tell founders to paste a full `sk_live_` Stripe key or classic GitHub PAT into `.env`.

If you only remember one security rule when wiring an agent to your live SaaS, make it this: **assume the agent will eventually read a malicious string inside a support ticket, GitHub issue, or scraped webpage.** When that happens, your safety comes from what the credential itself cannot do, not from how politely your system prompt asked the model to behave.

## Least-privilege scope table

**Minimum viable permissions across six founder tools. Start read-only everywhere; add single write scopes only behind an approval gate.**

|  | Service | Minimum scopes to grant | Explicitly omit |
| --- | --- | --- | --- |
| GitHub | Fine-grained PAT or GitHub App on 1 repo: Contents (Read), Issues (Read/Write if gated), Pull requests (Read), Metadata (Read). | Classic PAT, Administration, Secrets, Environments, Merge/Force-push to main. |
| Stripe | Restricted key (rk_live_): Subscriptions (Read), Invoices (Read), Customers (Read), Balance Transactions (Read), Prices (Read). | sk_live_ full key, Refunds, Payouts, Webhook endpoints, Checkout/Price writes. |
| PostHog | Scoped Personal API key (1 project): query:read, insight:read, event_definition:read, cohort:read. | Organization admin, project:write, feature_flag:write, person:delete. |
| Sentry | Organization Auth Token: event:read, project:read, org:read (plus project release read). | event:admin, project:admin, org:admin, member:write, DSN/key management. |
| Slack | Bot token in dedicated channels only: channels:history, channels:read, app_mentions:read (chat:write only if gated). | im:history (all DMs), users:read.email, admin.*, files:write across workspace. |
| Postgres | Dedicated role on read replica: CONNECT, USAGE, SELECT on non-secret reporting views, 5s statement_timeout. | SUPERUSER, INSERT/UPDATE/DELETE, access to auth/tokens/passwords tables. |

Before generating any key, decide which five tools your agent genuinely needs to read each morning. Most solo SaaS founders need six surfaces: GitHub, Stripe, PostHog, Sentry, Slack, and a reporting database view. Everything else stays disconnected until a real workflow requires it.

## Six copy-pasteable policies

- **rk_live_** Stripe key prefix (Restricted key with Read-only billing scopes; never sk_live_.)
- **1 repo** GitHub blast radius (Fine-grained PAT or App scoped to a single named repository.)
- **5,000 ms** Postgres timeout (Cap agent analytics queries so a bad JOIN cannot lock production.)
- **90 days** Token expiry (Rotate agent credentials quarterly alongside your permission audit.)

Use the exact configurations below when creating credentials for an AI co-founder or custom internal agent.

### 1. GitHub: Fine-grained PAT or dedicated GitHub App

Never use a classic personal access token (`ghp_...`), because a classic PAT grants access to every repository across every organization your personal account belongs to.

Create a **Fine-grained personal access token** (or a private GitHub App installed on one repository) with these exact settings:

- **Repository access:** *Only select repositories* -> pick the single product repo.
- **Expiration:** 90 days maximum.
- **Repository permissions:**
  - `Metadata`: Read-only (required by GitHub).
  - `Contents`: Read-only for morning reviews (or Read and write *only* if the agent pushes branches, paired with strict branch protection rules requiring PR review before `main`).
  - `Pull requests`: Read-only (or Read and write to open draft PRs, with **no** ability to bypass branch protection or merge).
  - `Issues`: Read and write *only* if gated behind human approval; otherwise Read-only.
- **Account permissions:** None. Never grant `Administration`, `Environments`, `Secrets`, or `Workflows` write permissions to an autonomous agent.

### 2. Stripe: Restricted API key (`rk_live_`)

Never hand a standard `sk_live_` secret key to an AI workspace. An `sk_live_` key can issue refunds, alter prices, cancel every customer's subscription, and modify webhook endpoints.

In the Stripe Dashboard (**Developers -> API keys -> Create restricted key**):

- **Core:** `Customers` (Read), `Charges` (Read), `Balance Transactions` (Read), `Events` (Read).
- **Billing:** `Subscriptions` (Read), `Invoices` (Read), `Prices` (Read), `Products` (Read), `Coupons` (Read).
- **Everything else:** `None`. Specifically verify `Write` is disabled on Refunds, Payouts, PaymentIntents, and Checkout.

With this `rk_live_` key, an agent can recompute MRR, detect dunning spikes, and spot failing renewals while having zero mechanical ability to touch a single cent.

### 3. PostHog: Scoped Personal API Key

In PostHog (**Settings -> Personal API Keys -> Create personal API key**), select **Scoped** rather than All Access, restrict it to your single production project, and grant only:

- `query:read` (to run HogQL/funnel summaries)
- `insight:read` and `dashboard:read`
- `event_definition:read` and `cohort:read`

Leave `project:write`, `feature_flag:write`, `action:write`, and `person:delete` unchecked so an agent cannot accidentally flip a production feature flag or purge user records.

### 4. Sentry: Minimal Organization Auth Token

Create an **Organization Auth Token** (or scoped Internal Integration token) in Sentry limited strictly to:

- `org:read`
- `project:read`
- `event:read`

Omit `project:admin`, `event:admin`, and `member:write`. That gives the agent stack traces, release regression counts, and issue frequencies without allowing it to resolve alerts silently, change alert rules, or delete issues.

### 5. Slack: Channel-scoped Bot Token

Slack's biggest risk is accidentally letting an agent read private executive DMs or post unreviewed announcements to `#general`. Create a dedicated Slack App with a Bot Token restricted to:

- `channels:read` and `channels:history` (only in channels where you explicitly `/invite` the bot, such as `#ops-alerts` or `#founder-brief`).
- `app_mentions:read`.
- Omit `im:history`, `mpim:history`, `groups:history` (unless explicitly invited to one private ops channel), and `users:read.email`. If the bot only reads context and posts approvals back to you in a private DM thread, keep `chat:write` scoped out of public customer channels.

### 6. Postgres: Read-only reporting role on a replica

Never connect an agent directly to your primary application `postgres` role. Create a dedicated read-only user pointing at a read replica (or a dedicated schema of safe views excluding password hashes, OAuth tokens, and session tables):

```sql
CREATE ROLE agent_readonly WITH LOGIN PASSWORD 'replace-with-strong-secret';
ALTER ROLE agent_readonly SET default_transaction_read_only = on;
ALTER ROLE agent_readonly SET statement_timeout = '5000ms';

CREATE SCHEMA IF NOT EXISTS agent_views;
GRANT USAGE ON SCHEMA agent_views TO agent_readonly;
GRANT SELECT ON ALL TABLES IN SCHEMA agent_views TO agent_readonly;
REVOKE ALL ON SCHEMA public FROM agent_readonly;
```

Putting `default_transaction_read_only = on` and `statement_timeout = '5000ms'` at the database role level guarantees no SQL injection or clumsy aggregation can mutate rows or starve production CPU.

## Why credential isolation beats prompt rules

> **Do not export API keys into the agent VM** Even a read-only token should not sit in plain environment variables inside a coding VM that runs untrusted npm packages or reads external issues. Keep credentials inside a broker outside the sandbox that injects scoped auth headers only onto allowlisted API calls.

Even with narrow read-only keys, **never store those tokens inside the same Linux container where the agent runs shell commands or executes repository tests.** A coding agent installing an npm dependency or reading an untrusted GitHub issue runs arbitrary code inside its VM; any secret in `process.env` can be printed or curled out.

Run a lightweight **credential broker** outside the sandbox. The VM calls an authenticated local/internal proxy endpoint; the broker verifies the destination host, enforces your approval policy for any write method, attaches the restricted token in memory, and returns the sanitized JSON response.

You can bundle these exact scope checklists and repository guardrails with the [Agent Guardrails Pack](/packs/agent-guardrails), generate a clean policy header for your repo using the [AGENTS.md generator](/tools/agents-md), or package safe workspace context with the [Context Pack tool](/tools/context-pack).

## Questions people ask

### What GitHub token scope should a solo founder give an AI agent?

Use a fine-grained Personal Access Token or a GitHub App restricted to a single repository, expiring within 90 days. Grant Read-only access to Metadata, Contents, and Pull requests, and add Issues write access only behind a human approval gate while keeping Administration, Secrets, and main-branch merge permissions disabled.

### How do I connect Stripe safely to an AI co-founder?

Create a Stripe restricted API key (rk_live_) instead of using a full sk_live_ secret key. Grant Read permission only on Subscriptions, Invoices, Customers, Balance Transactions, Prices, and Coupons, and leave Write disabled across Refunds, Payouts, and Billing edits.

### Why is a read-only Postgres role not enough without a statement timeout?

A read-only role stops data mutation, but an unindexed SELECT across millions of event rows can still exhaust memory or lock connection pools on your database. Always pair a reporting-view schema with a short statement_timeout (such as 5,000 ms) and point the role at a read replica when possible.

### Should an AI agent hold API keys inside its sandbox environment variables?

No. If an agent executes code, installs packages, or reads untrusted web pages inside a VM, any token in environment variables can be read and exfiltrated. Keep credentials in an external credential broker that attaches headers per allowlisted request outside the sandbox.

### How often should a solo founder audit agent tokens?

Set a 90-day expiration on fine-grained tokens and review active scopes quarterly. Remove any integration the agent has not queried in 30 days, and immediately revoke tokens if a third-party dependency or prompt-injection alert occurs.

## Sources

Checked 2026-11-22.

- [GitHub Docs: Fine-grained personal access tokens](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens)
- [Stripe Docs: Restricted API keys](https://docs.stripe.com/keys#limit-access)
- [PostHog Docs: Personal API keys & scopes](https://posthog.com/docs/api)
- [Sentry Docs: Auth tokens & scopes](https://docs.sentry.io/api/auth/)
- [Slack Docs: Bot token scopes](https://api.slack.com/scopes)
- [Founder2 Agent Guardrails Pack](https://tryfounder2.com/packs/agent-guardrails)
- [Founder2 AGENTS.md generator](https://tryfounder2.com/tools/agents-md)
- [Founder2 Context Pack tool](https://tryfounder2.com/tools/context-pack)
