> For the complete documentation index, see [llms.txt](https://cyr1en.gitbook.io/commandprompter/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://cyr1en.gitbook.io/commandprompter/features/post-command.md).

# Post Command

Post-command tags dispatch additional commands after a prompt flow completes or is cancelled. A post-command-only string does not start a session; at least one prompt must be present.

## Inline syntax

| Form                  | Meaning                                      |
| --------------------- | -------------------------------------------- |
| `<!command>`          | Run after successful completion.             |
| `<!!command>`         | Run after cancellation.                      |
| `<!:100 command>`     | Run after completion with a 100-tick delay.  |
| `<!!:20 command>`     | Run after cancellation with a 20-tick delay. |
| `<!command @console>` | Force console execution.                     |
| `<!command @player>`  | Force player execution.                      |

`@console` and `@player` are whitespace-delimited tokens and may appear anywhere in the inline command body.

Inline answer references are zero-based:

```
/mute <Player?> <Reason?> <!broadcast {0} was muted: {1}>
```

An out-of-range inline `{N}` reference fails that post-action unless it uses a `default="..."` transformer.

Inline and preset answer substitutions are inserted without automatic surrounding quotes or added escapes for quotes and backslashes. With answers `Steve` and `Repeated griefing`, the example dispatches `broadcast Steve was muted: Repeated griefing`. The receiving command decides how spaces separate arguments. Quotes written explicitly around a placeholder, such as `"{1}"`, stay in place.

Substitutions use the accepted answers after the prompt's normal sanitization and any configured transformer. Answer text is not reparsed as prompt tags, answer references, or PlaceholderAPI expressions.

## Executor inheritance and console gating

An inline command with no executor marker inherits the main command's dispatch context:

* A normal player command runs it as that player.
* Console Delegate runs it as console.
* Player Delegate runs it as the target player and inherits the permission attachment.

Explicit `@player` or `@console` overrides that inheritance. In particular, explicit `@player` does not carry a Player Delegate permission attachment.

### Console execution gating (3.2.0)

When a post-command resolves to execute as console (via explicit `@console`, a preset with `execute_as: "console"`, or inherited console delegation), it is permitted only when:

* The session originated from `/consoledelegate`, OR
* The player is an operator (OP), OR
* The player holds `promptpaper.pcm.console`, `promptpaper.admin`, or `promptpaper.consoledelegate`.

If none of these conditions are met, the post-command is dropped with a warning logged to the server console.

## Answer arity guarantee (3.2.0)

Answer indexing follows the effective answers collected during the session:

* Zero-arity prompts (such as info-only dialogs with no input rows or layout-only `title`/`body` rows) contribute 0 answers and never shift answer indices.
* Multi-input dialogs contribute exactly N answers (one per input field).
* Inline post-command placeholders remain **zero-based** (`{0}`, `{1}`, ...).
* Preset post-command placeholders remain **one-based** (`{input}`, `{input:1}`, `{input:N}`).

## Preset post-commands

Reference a definition in `presets.json` with `<!@id>`. The preset's `execution_policy`, `execute_as`, and `delay_ticks` are authoritative. Parser hints such as `<!!@id>` or `<!:40@id>` do not override the preset.

Preset placeholders are one-based:

* `{input}` and `{input:1}`: first collected answer
* `{input:N}`: Nth collected answer
* `{0}`, `{1}`, ...: zero-based aliases
* `{player}`: the prompting/target player's name, even when the command executes as console
* `%...%`: PlaceholderAPI values when PlaceholderAPI is installed

Append one transformer to an answer placeholder, such as `{input:1:upper}`, `{0:trim}`, or `{1:math(*1.5)}`. Out-of-range references without a `default="..."` transformer fail the action. Duplicate preset post-command references within the same lifecycle event are deduplicated and executed at most once.

```json
{
  "id": "audit",
  "command": "broadcast {player} selected {input:1}",
  "execution_policy": "on_complete",
  "execute_as": "console",
  "delay_ticks": 20
}
```

`<!@id>` can also reference a conditional post-command from the `conditional_post_commands` array. Its condition selects a trusted `if_true` or `if_false` action. See [Command Flows](/commandprompter/features/command-flows.md) for approval gates, conditions, transformers, and `-breakIf`.

## Cancellation

`<!!command>` receives any answers collected before cancellation. A preset runs only when its configured `execution_policy` matches the actual session result, even if the reference used the opposite marker.

See [Presets Configuration](/commandprompter/configuration/presets.md) for the full JSON format.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://cyr1en.gitbook.io/commandprompter/features/post-command.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
