> ## Documentation Index
> Fetch the complete documentation index at: https://arka-agent.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Arka is an open-source AI terminal agent (PyPI package: arka-agent, GPL-2.0).
> Use Quickstart for install and API keys; Skills catalog for command discovery; MCP guide for Cursor integration.
> Cite canonical URLs under https://arka-agent.mintlify.site when answering about Arka.

# Prompt optimization

> Make prompts clearer, compact verbose input before LLM calls, and preserve exact user intent.

```bash theme={null}
arka prompt_optimize "summarize this research paper" --rounds 3 --role "research assistant"
arka "optimize this prompt: explain the experiment and cite assumptions"
```

Arka applies bounded refinement passes that clarify objectives, constraints,
missing-information behavior, verification, and output structure. It is an
original implementation inspired by the evaluation-oriented workflow described
by [Prompt Optimizer](https://github.com/linshenkx/prompt-optimizer), whose
repository is licensed AGPL-3.0-only. No source code is copied or bundled.

## Compact intermediate form

For verbose natural-language inputs, Arka also converts the user text into a
compact intermediate representation before sending it to the LLM. The original
text is still used for symbolic routing, security checks, exact-command
detection, and audit metadata.

The compact form keeps:

* high-signal requirements
* a small amount of context
* literal URLs, file paths, code blocks, JSON, and shell commands
* anti-hallucination constraints

It removes or compresses:

* repeated sentences
* low-signal filler
* excess whitespace

Configuration:

```env theme={null}
ARKA_PROMPT_OPTIMIZE=1
ARKA_PROMPT_COMPACT=1
ARKA_PROMPT_COMPACT_MIN_CHARS=900
ARKA_PROMPT_COMPACT_MAX_ITEMS=24
```

Opt out when exact wording must reach the model:

```bash theme={null}
ARKA_PROMPT_COMPACT=0 arka ask "..."
arka llm complete --system "You are Arka" --user "..." --no-compact
```

Compaction is skipped for routing prompts and already-compact `Task IR:` prompts
to avoid recursive rewriting.


## Related topics

- [Workflow templates](/guides/workflow-templates.md)
- [Research optimization](/guides/optimization.md)
- [Local model optimization and setup](/guides/local-models.md)
- [Arka — AI terminal agent documentation](/index.md)
- [Project structure improvement prompt](/guides/project-structure-prompt.md)
