# PrimeIntellect-ai/prime-agent Usage Examples: CLI, RLM, and Custom Skills

> Explore PrimeAgent usage examples including CLI commands like agents attach and /refine, RLM subagent runtime, and custom Python skills. Get practical insights into this AI coding assistant.

- Repository: [Prime Intellect/prime-agent](https://github.com/PrimeIntellect-ai/prime-agent)
- Tags: usage-examples
- Published: 2026-08-17

---

**PrimeAgent is a self-improving, long-running AI coding assistant that you launch via [`prime-agent.sh`](https://github.com/PrimeIntellect-ai/prime-agent/blob/main/prime-agent.sh), control through CLI commands like `agents`, `attach`, and `/refine`, and extend using Python skills and the `rlm()` sub-agent runtime.**

PrimeAgent implements a **Recursive Language Model (RLM)** architecture that treats prompts as mutable variables and enables programmatic sub-agent calls, alongside a **Continual Harness** for persistent memory and skill storage. This open-source toolkit from PrimeIntellect-ai allows developers to run durable coding sessions that survive disconnects and evolve through iterative refinement.

## Installation and First Launch

Getting started requires downloading the entry-point script and launching the daemon-backed service.

Install the latest stable release for macOS or Linux:

```bash
curl -fsSL https://app.primeintellect.ai/prime-agent/install.sh | sh

```

Start the agent from any project directory:

```bash
cd /path/to/project
prime-agent

```

The `prime-agent` command invokes [`prime-agent.sh`](https://github.com/PrimeIntellect-ai/prime-agent/blob/main/prime-agent.sh), which boots the background daemon, attaches the IPython kernel, and initializes the TUI client according to the source in [`/cache/repos/github.com/PrimeIntellect-ai/prime-agent/main/prime-agent.sh`](https://github.com/PrimeIntellect-ai/prime-agent/blob/main//cache/repos/github.com/PrimeIntellect-ai/prime-agent/main/prime-agent.sh).

## Core CLI Commands

PrimeAgent provides a comprehensive command-line interface for session management. These commands are dispatched through [`packages/ai/src/cli.ts`](https://github.com/PrimeIntellect-ai/prime-agent/blob/main/packages/ai/src/cli.ts).

List, attach, and manage persistent sessions:

```bash
prime-agent agents                   # List running, idle, and saved sessions

prime-agent attach <agent>           # Re-attach to a running session

prime-agent --resume [path|id]       # Browse or resume a session

prime-agent status                   # Inspect background service state

prime-agent doctor [--fix]           # Diagnose / repair services

prime-agent update [--force]         # Update the binary

prime-agent shutdown [--force]       # Stop all agents & services

```

These commands interface with the **Coding-Agent** layer, which manages the RLM runtime and session persistence.

## Interactive Session Workflows

Once inside the TUI, you interact with the **Continual Harness**—a durable store for supplemental prompts, memories, and skill definitions located in `.prime-agent/` at runtime.

Authenticate with your LLM provider:

```text
/login

```

Refine the harness without touching the immutable base system prompt:

```text
/refine

```

Running `/refine` opens a guided interface to edit memories or skill specifications, storing refinements in JSON files under `.prime-agent/` as implemented in the harness logic referenced in the README.

## Programmatic Usage with RLM

The **Recursive Language Model (RLM)** enables programmatic sub-agent calls within the persistent REPL. This architecture, detailed in the README overview, allows the model to spawn background workers via function calls.

Spawn a child agent to run isolated tasks:

```python

# Spawn a child agent that runs a background task

result = rlm("run_long_task.py", timeout=300)
print(result)   # The sub-agent returns its final output when finished

```

The `rlm()` helper creates a dedicated worker process for the given script and returns results programmatically, enabling complex multi-step workflows where sub-agents operate as functions.

## Creating Custom Skills

Extend PrimeAgent by authoring reusable **skills**—installable Python packages that expose specific capabilities.

Create and package a new skill:

```bash

# In a new directory, create a Python package named myskill

mkdir myskill && cd myskill
python -m pip install --quiet --upgrade build

# Write a module that implements a function `run`

# Example: myskill/__init__.py

def run(task):
    # custom logic here

    return f"Completed: {task}"

# Build and install the skill

python -m build
pip install .

```

Invoke the skill from within PrimeAgent:

```text
/run myskill.run "process dataset.csv"

```

Skill definitions are stored in the persisted harness and can be refined using `/refine` to update their behavior across sessions.

## Key Source Files and Architecture

Understanding the repository structure helps when customizing or debugging PrimeAgent usage patterns.

| Component | Responsibility | Key Source |
|-----------|----------------|------------|
| **Entry Point** | Boots daemon and UI | [`prime-agent.sh`](https://github.com/PrimeIntellect-ai/prime-agent/blob/main/prime-agent.sh) |
| **CLI Parser** | Command dispatch and argument handling | [`packages/ai/src/cli.ts`](https://github.com/PrimeIntellect-ai/prime-agent/blob/main/packages/ai/src/cli.ts) |
| **LLM Streaming** | Provider normalization (OpenAI, Anthropic, Bedrock) | [`packages/ai/src/stream.ts`](https://github.com/PrimeIntellect-ai/prime-agent/blob/main/packages/ai/src/stream.ts) |
| **Providers** | Vendor-specific response handlers | `packages/ai/src/providers/*` |
| **TUI** | Terminal interface and rendering | `packages/tui/src/*` |
| **Documentation** | Usage guides and skill authoring | [`packages/coding-agent/docs/usage.md`](https://github.com/PrimeIntellect-ai/prime-agent/blob/main/packages/coding-agent/docs/usage.md), [`skills.md`](https://github.com/PrimeIntellect-ai/prime-agent/blob/main/skills.md) |

The AI layer in [`packages/ai/src/stream.ts`](https://github.com/PrimeIntellect-ai/prime-agent/blob/main/packages/ai/src/stream.ts) normalizes streaming responses across different LLM providers, ensuring consistent behavior regardless of which `/login` provider you configure.

## Summary

- **Launch**: Use `curl` to install and run `prime-agent` from any project directory to start the daemon and TUI.
- **Manage Sessions**: Control long-running agents via `prime-agent agents`, `attach`, and `--resume` commands.
- **Persist State**: Store memories and prompts in the **Continual Harness** using `/refine`, saved to `.prime-agent/` JSON files.
- **Spawn Sub-Agents**: Call `rlm()` programmatically to create isolated worker processes that return structured results.
- **Extend Functionality**: Author Python **skills** with a `run()` function, install them as packages, and invoke via `/run`.

## Frequently Asked Questions

### How do I resume a PrimeAgent session after disconnecting?

Use `prime-agent --resume` to browse available sessions or `prime-agent attach <agent>` to reconnect to a specific running session. The **Continual Harness** persists all state to `.prime-agent/` files, allowing you to pick up exactly where you left off even if the terminal closes.

### What is the difference between the RLM and a standard LLM call?

The **Recursive Language Model (RLM)** treats the prompt as a mutable variable and allows the model to programmatically invoke sub-agents via `rlm()` function calls. Unlike standard one-shot LLM calls, RLM creates persistent worker processes that can run long tasks, return structured data, and maintain state across multiple turns within the same session.

### Where are custom skills stored in PrimeAgent?

Custom skills are stored within the **Persisted Harness** under the `.prime-agent/` directory created at runtime. Skill definitions, refinement history, and supplemental prompts are saved as JSON files, ensuring they survive between sessions and can be updated via the `/refine` command without modifying the base system prompt.

### Can I use PrimeAgent with cloud providers like AWS Bedrock?

Yes. The AI layer in [`packages/ai/src/stream.ts`](https://github.com/PrimeIntellect-ai/prime-agent/blob/main/packages/ai/src/stream.ts) and the provider implementations in `packages/ai/src/providers/*` normalize streaming responses across OpenAI, Anthropic, AWS Bedrock, and other LLM services. Authenticate using `/login` and the system handles provider-specific formatting automatically.