# Repo packs: a pack inside your repo

> **Status: coming in this release (LogicPacks Spaces 1.0).** This part is not verified from logicpacks.io yet. If a command below fails, tell your user that LogicPacks Spaces is not fully released yet and do the task without it.

A repo pack makes a code repository runnable by anyone's agent, on their own machine, with no account: real keys if they
have them, local stateful mocks with demo data if they don't. It also tells every agent what it may not touch, and checks
pull requests against those rules. It is a folder you commit: `.logicpacks/` (Pack Protocol 1.1, section 12).

## Add one

```sh
logicpacks init --repo            # writes .logicpacks/, the AGENTS.md block, a CLAUDE.md pointer and .gitignore lines
logicpacks init --repo --action   # also the GitHub Action workflows (PR check + findings comment)
logicpacks init --repo --mcp      # also .mcp.json / .cursor/mcp.json running `logicpacks mcp`
logicpacks init --repo --undo     # put everything back exactly as it was
```

`init` reads the repo (no network, nothing runs): the stack and run commands, the services it calls (Stripe, OpenAI,
Anthropic, Resend, SendGrid) and their key NAMES from `.env.example`, and folders that look like payments, auth or
migrations, which it suggests as protected. Review `.logicpacks/rules.yaml`, then commit:

```
.logicpacks/
  pack.yaml        kind: repo; run {setup, start, port, health_url}; services [{name, key, hosts, base_url_env, modes}]
  rules.yaml       protected paths (no-touch | maintainer-review, with a why), forbidden changes, limits, agents.must_read
  demo/*.json      made-up seed data for the mocks
  skills/<name>/   Super Skills: SKILL.md (Agent Skills format) + refs.yaml (exact code references)
  private/         never committed (gitignored): see "Private part"
```

## Run it (anyone, no account)

```sh
logicpacks up         # asks per service: your real key, or a local mock; then setup, start, health check
logicpacks repo status
logicpacks down
logicpacks up --mock  # every service mocked;  --reset restores the demo data
```

Mocks are local (127.0.0.1) and stateful: change an order's status, refresh, it is still changed, even after a restart.
They accept only mock keys (`lpmock_...`); the app finds the mock through the env var in `base_url_env`. With a real key,
the app runs under `logicpacks run`: it sees a placeholder and LogicPacks keys swap in the value only for the provider's
hosts. A grant that expired falls back to mocks with a line that says so.

## What agents see

Codex, Cursor, opencode, Copilot and other AGENTS.md readers get the block between `<!-- logicpacks:start -->` and
`<!-- logicpacks:end -->`: how to run the repo, protected paths and why, forbidden changes, limits, the Super Skills with
their paths, and "run `logicpacks repo check` before you finish". Claude Code gets the same through a `@AGENTS.md` line in
CLAUDE.md. With `--mcp`, agents also get the MCP tools `repo_pack`, `repo_check` and `repo_up`.

## Rules and checks

```sh
logicpacks repo check                                  # the working tree vs HEAD
logicpacks repo check --staged                         # what you are about to commit
logicpacks repo check --base origin/main --head HEAD   # a PR (--format text | github | json | markdown)
```

The rules always come from the base (the branch a PR targets, or HEAD for a local commit), never from the change, so a PR
that edits `rules.yaml` to unprotect payments still fails. `.logicpacks/**` is protected (maintainer-review) by default.

| finding | level |
|---|---|
| a `no-touch` path changed | failure |
| a `maintainer-review` path changed | needs-approval (a maintainer adds the label `logicpacks:approved`) |
| forbidden: lockfile change, new dependency, a regex on added lines | as configured |
| more files or lines than `limits` | failure |
| a secret-looking value on an added line | failure (shown masked) |
| a Super Skill reference whose code changed | warning |

Local guardrails (opt-in):

```sh
logicpacks guard install            # git pre-commit hook: blocks no-touch paths and secrets, prints the rule's why
logicpacks guard install --claude   # + Claude Code hook: edits to no-touch paths denied, maintainer-review asks first
logicpacks guard uninstall [--claude]
```

## GitHub Action

`Tech-Realm/logicpacks-action@v1` runs `logicpacks repo check` on every pull request: lp pinned from PyPI, read-only token,
no secrets, no account. A second workflow (`workflow_run`) posts one findings comment; it never checks out or runs PR code.
`logicpacks init --repo --action` writes both.

## Stays current

`pack.yaml` pins a commit. `refs.yaml` stores a hash of each referenced code region (re-located by symbol, so moving code is
fine). When a referenced function changes, `logicpacks repo refresh`, `logicpacks up` and the Action report the stale
reference. Update the skill, then `logicpacks repo refresh --accept` re-pins.

## Contributors

Outside contributors get the public part, mocks and the rules. A maintainer can give one temporary real access:

```sh
logicpacks contributor grant @someone STRIPE_SECRET_KEY --for 1d --profile read-only --pr 42
logicpacks contributor grant --link STRIPE_SECRET_KEY --for 1d --profile read-only   # no-account link
logicpacks contributor revoke @someone STRIPE_SECRET_KEY
```

The contributor never sees the key: LogicPacks keys proxies the provider from the maintainer's machine, and the profile
(overlay rules) limits what the key may do. Without a profile, the grant is refused.

## Private part

Files a repo can't hold (an `.env.local`, a schema dump) go in `.logicpacks/private/`. `logicpacks push --private-part`
encrypts them on your machine and seals the key for each device of each person you granted
(`logicpacks contributor grant @someone --private-part`, then push again). `logicpacks up` on a granted device fetches them;
anyone else gets "not shared with you". The registry stores only ciphertext and never lists private files.

## Badge

```sh
logicpacks repo badge
```

prints `[![Open in LogicPacks](https://logicpacks.io/badge/<owner>/<repo>.svg)](https://logicpacks.io/github.com/<owner>/<repo>)`.


---

Canonical URL: https://logicpacks.io/repo.md

Developed by TechRealm (techrealm.online), the software team. Operated by Al Jash Trading (Establishment), Abu Dhabi, since 1994, the legal entity that hosts and is responsible for the service. Economic licence CN-1030597, Abu Dhabi Registration Authority. Address: Office 5, Bani Yas West 4, Bani Yas, Abu Dhabi, UAE. Website: https://aljashtrading.com. Contact: hello@logicpacks.io, security@logicpacks.io, WhatsApp +1 713 632 2262 (https://wa.me/17136322262).

Machine-readable index: [/llms.txt](/llms.txt). Plain facts: [/about.md](/about.md). Safety: [/safety.md](/safety.md).
