CLI Reference

Complete reference for the af command-line tool.

Installation

# Install (macOS / Linux)
curl -sL https://dev.alwaysforever.ai/af > /usr/local/bin/af && chmod +x /usr/local/bin/af

# Verify installation
af help

Requirements: bash, curl, python3 (for JSON formatting). No other dependencies.

Setup

af init <api-key>

Save your API key locally. The key is stored at ~/.alwaysforever with 600 permissions (owner-only read/write).

af init af_live_hiWlflSDD3LpOlJv9wC4QJbCxCQHXb2dYPvMj6fZrZg
✓ API key saved to /home/user/.alwaysforever
✓ Key verified — you're connected to AlwaysForever.ai

Alternative: Set the AF_API_KEY environment variable instead of running af init.

export AF_API_KEY=af_live_YOUR_KEY

Memory Commands

af store <content>

Store a memory. Memories are automatically enriched with semantic tags and embeddings.

FlagDefaultDescription
--typestmMemory type: stm, conversation, or event
--stm-typeinsightSTM category (see table below)
--importance0.5Importance score from 0.0 to 1.0

STM types:

TypeUse forExample
decisionStrategic choices"Switched to PostgreSQL for persistence"
workCode changes, fixes"Fixed auth middleware timeout bug"
insightRealizations, patterns"User asks about deployment every Monday"
lessonThings learned"Always validate JWT before parsing claims"
checkpointMilestones"v2.0 API migration complete"
bugIssues found"Race condition in session cleanup"
errorErrors encountered"ModuleNotFoundError: redis"
# Basic store (defaults to STM insight)
af store "User prefers dark mode"

# Store a high-importance decision
af store "Migrated from REST to GraphQL" --stm-type decision --importance 0.9

# Store a conversation message
af store "How do I reset my password?" --type conversation

# Store a system event
af store "Deployment to staging complete" --type event

af recall <query>

Semantic search across all your memories. Returns the most relevant results.

FlagDefaultDescription
--limit10Maximum number of results (1-200)
--hoursall timeOnly search within last N hours
# Search all memories
af recall "user preferences"

# Search recent memories only
af recall "deployment issues" --hours 24

# Get more results
af recall "architecture decisions" --limit 50

af recent [limit]

Get the most recent memories, sorted by time. Useful for session continuity.

# Last 20 memories (default)
af recent

# Last 5 memories
af recent 5

Platform Commands

af sessions

List all sessions for your account.

af sessions

af health

Check platform health status. This endpoint is public (no API key required).

af health

af whoami

Verify your connection and show account info.

af whoami

Environment Variables

VariableDescription
AF_API_KEYAPI key (alternative to af init)
AF_BASE_URLOverride base URL (default: https://dev.alwaysforever.ai)
AF_CONFIGOverride config file path (default: ~/.alwaysforever)

Integration Examples

Python

# pip install httpx
import httpx

client = httpx.Client(
    base_url="https://dev.alwaysforever.ai",
    headers={"Authorization": f"Bearer {api_key}"}
)

# Store a memory
client.post("/v1/memory/store", json={
    "type": "stm",
    "content": "User prefers concise responses",
    "stm_type": "insight",
    "importance": 0.8
})

# Recall memories
result = client.post("/v1/memory/recall", json={
    "query": "user preferences",
    "limit": 10
})
memories = result.json()

JavaScript / Node.js

const AF_KEY = process.env.AF_API_KEY;
const BASE = "https://dev.alwaysforever.ai";

// Store a memory
await fetch(`${BASE}/v1/memory/store`, {
  method: "POST",
  headers: {
    "Authorization": `Bearer ${AF_KEY}`,
    "Content-Type": "application/json"
  },
  body: JSON.stringify({
    type: "stm",
    content: "User prefers dark mode",
    stm_type: "insight"
  })
});

// Recall memories
const res = await fetch(`${BASE}/v1/memory/recall`, {
  method: "POST",
  headers: {
    "Authorization": `Bearer ${AF_KEY}`,
    "Content-Type": "application/json"
  },
  body: JSON.stringify({ query: "user preferences", limit: 10 })
});
const memories = await res.json();