# Agents and permissions (/docs/agents-and-permissions)

An agent profile is the engine's set of permission rules for the agent in a session. It is not the agent CLI. It is
what the engine checks before a tool call runs. Each check ends in one of three effects: `allow`, `ask` or `deny`.

## Set rules in your config [#set-rules-in-your-config]

```ts twoslash title="vite.config.ts"
import {defineConfig} from 'vite'
import conciv from '@conciv/it/plugin/vite'

export default defineConfig({
  plugins: [
    conciv({
      permission: {page_eval: 'allow'}, // <- runs JavaScript in the page with no card
      permissions: [
        {action: 'server_restart', resource: '*', effect: 'deny'}, // <- never restarts the dev server
      ],
    }),
  ],
})
```

<Playground
  page="vite-react"
  script="approvals/allow-once"
  caption="A Permission card in the chat, answered with Allow once."
/>

## Agent profile [#agent-profile]

The engine starts with one profile, `build`. It allows every action. It asks before it reads a `.env` file, but not
`.env.example`. Plugins can change a profile. The engine adds your config rules to every profile. Learn more in
[Ask for permission](/docs/plugins/guides/permission).

## Rules [#rules]

A rule has an action, a resource and an effect. The action is the tool's name, such as `page_eval`. The resource is
what it acts on, such as the code it would run. Both take `*` as a wildcard. Learn more in [Configuration](/docs/reference/configuration#permission).

## The order rules apply in [#the-order-rules-apply-in]

The last rule that matches decides. The engine reads them in this order:

1. the agent profile's rules: its built-in ones, the ones plugins add and your config rules.
2. the tool's fallback, below.
3. the session's own rules, which a plugin can set for one session.
4. your saved answers.

A `deny` among the first three always wins, before any saved answer is read. When no rule matches, the call asks.

## Fallback ask [#fallback-ask]

A risky tool asks for `fallback: 'ask'`. Then a call that only the catch-all `*` rule allows asks you instead. That is
why the `build` profile allows everything, yet running JavaScript in the page still asks. A rule that names the action,
such as `{page_eval: 'allow'}`, skips the card.

## The ask card [#the-ask-card]

An `ask` shows a **Permission** card in the chat. The call waits until you answer:

- **Allow once** (⌘ Enter or Ctrl Enter) runs this one call.
- **Allow always** runs it and saves the answer. It shows only when the tool offers a saved answer.
- **Deny** (Escape) refuses the call. Every other card waiting in the same session is refused with it.

Your agent CLI's own asks, from Claude Code or Gemini CLI, use the same card. They can be allowed once or denied, never
allowed always. Learn more in [Approvals](/docs/usage/approvals).

## Saved answers [#saved-answers]

**Allow always** saves an `allow` rule for the call's action and resources. The engine keeps it for this project, in the
`permission` table of `.conciv/conciv.db`. It applies to every session. Saved answers come last, so a saved answer
beats an `ask` rule from your config. Only a `deny` rule beats it.

<Callout type="warn" title="Ask on every call">
  A rule cannot make a call ask every time once it has been allowed always. A tool that must always ask leaves out its
  saved answer, so the card has no **Allow always** button. Running JavaScript in the page works this way.
</Callout>

## Forget a saved answer [#forget-a-saved-answer]

conciv has no button or command to forget a saved answer yet. Delete its row from the database instead. List them
first:

```bash title="Terminal"
sqlite3 .conciv/conciv.db "select action, resource from permission"
```

Then delete the one you no longer want:

```bash title="Terminal"
sqlite3 .conciv/conciv.db "delete from permission where action = 'server_restart'"
```

The engine reads saved answers on every check, so the next call asks again.

## A deny in plugin code [#a-deny-in-plugin-code]

A tool that asks fails its call when you deny. In a Promise plugin, the ask rejects. In an Effect plugin, a deny rule
fails it with a `Tool.Error`. A plain **Deny** on the card is different: it interrupts the effect as a defect, so
`catchTag` never sees it. Learn more in [Ask for permission](/docs/plugins/guides/permission).

## Outside agents [#outside-agents]

An agent connected from your own terminal can use your open tabs. With `hubAccess: 'project'`, its first call shows a
card in the tab. An outside agent can never answer a card itself. Learn more in [Configuration](/docs/reference/configuration#hubaccess).

## Next steps [#next-steps]

- **[Approvals](/docs/usage/approvals):** which tools and CLIs ask, and how you answer.
- **[Ask for permission](/docs/plugins/guides/permission):** make your own tool ask before it acts.
- **[Configuration](/docs/reference/configuration):** the `permission`, `permissions` and `policies` options.
