# Skill: remote-memory (HTTP)

You have access to a **global remote memory store** over HTTP. Use it whenever the user wants to remember, recall, save, or search persistent knowledge across sessions.

## Configuration

- **Base URL:** `https://llmcontext.duckdns.org`
- **Auth:** `Authorization: Bearer <token>`
- Use the API token from env `MEMORY_API_TOKEN` (Bearer token issued in the memory admin UI → API Tokens).
- **OpenAPI (machine-readable):** `https://llmcontext.duckdns.org/openapi.json`
- **Swagger UI:** `https://llmcontext.duckdns.org/docs`
- **JSON guide:** `https://llmcontext.duckdns.org/api/guide`
- **This skill prompt:** `https://llmcontext.duckdns.org/api/skill-prompt`

All successful JSON responses use `{"ok": true, ...}`. Errors use `{"ok": false, "error": "..."}`.

## When to use

- User says "remember this", "save this", "note that", "what did we decide", "search memory"
- Capture decisions, facts, preferences, tasks, code snippets, references
- Recall prior context that is not in the current chat

## When NOT to use

- Ephemeral scratch notes for a single turn
- Storing secrets/passwords/API keys into memory

## API operations

### 1. Search / list memories (`memory:read`)

```http
GET https://llmcontext.duckdns.org/api/memories?q={query}&type={optional}&scope={optional}&limit=20&page=1
Authorization: Bearer ${MEMORY_API_TOKEN}
```

- Omit `q` to list newest first.
- Pagination: `page` (1-based) + `limit` (1–200).
- Response fields: `rows[]` (id, title, type, tags, scope, snippet, timestamps), `total`, `page`, `page_size`, `total_pages`.

### 2. Get full memory (`memory:read`)

```http
GET https://llmcontext.duckdns.org/api/memories/{id}
Authorization: Bearer ${MEMORY_API_TOKEN}
```

Returns `memory` including full `content` (markdown).

### 3. Store memory (`memory:write`)

```http
POST https://llmcontext.duckdns.org/api/memories
Authorization: Bearer ${MEMORY_API_TOKEN}
Content-Type: application/json

{
  "content": "required markdown body",
  "title": "optional",
  "type": "note|fact|decision|task|preference|reference|code|conversation",
  "scope": "global|project|agent|user",
  "tags": ["optional", "tags"]
}
```

Rules:
- One memory = one clear idea (split compound notes).
- Prefer `type=decision` for choices + rationale; `fact` for verified info; `preference` for durable prefs.
- Default scope `global` unless project-specific.

### 4. Delete memory (`memory:delete`)

```http
DELETE https://llmcontext.duckdns.org/api/memories/{id}
Authorization: Bearer ${MEMORY_API_TOKEN}
```

### 5. Stats (`memory:read`)

```http
GET https://llmcontext.duckdns.org/api/stats
Authorization: Bearer ${MEMORY_API_TOKEN}
```

## Recommended workflow

1. **Recall first** when the user asks about past decisions: `GET /api/memories?q=...`
2. Show top snippets; only `GET /api/memories/{id}` when full body is needed.
3. **Store** after confirming content; return the new `id` to the user.
4. On HTTP 401: token missing/expired — tell the user to create a token in the admin UI.
5. On HTTP 403: wrong scope — need a token with read/write/delete as appropriate.

## Install as a local skill (for coding agents)

Create `SKILL.md` (or the tool's skill path) with:

```yaml
---
name: remote-memory
description: >-
  Remote global memory via HTTP API at https://llmcontext.duckdns.org. Use when the user wants to
  remember, recall, search, or persist knowledge across sessions.
---
```

Then paste the rest of this document as the skill body. Set env:

```bash
export MEMORY_API_BASE="https://llmcontext.duckdns.org"
export MEMORY_API_TOKEN="mem_tok_…"   # from admin UI → API Tokens (copy once)
```

## Quick curl checks

```bash
curl -sS -H "Authorization: Bearer ${MEMORY_API_TOKEN}" \
  "https://llmcontext.duckdns.org/api/memories?q=test&limit=5"

curl -sS -X POST -H "Authorization: Bearer ${MEMORY_API_TOKEN}" \
  -H "Content-Type: application/json" \
  -d '{"content":"Hello remote memory","type":"note","tags":["test"]}' \
  "https://llmcontext.duckdns.org/api/memories"
```
