---
name: Memory Management
description: Read and write persistent memory files that carry context across tasks
argument-hint: list | read <filename> | write <filename> | delete <filename>
---

# Memory Management Skill

Manage persistent memory files for your environment. Memory carries context, corrections, and learned information across tasks.

**IMPORTANT**: Memory writes persist across all future tasks in this environment. Be thoughtful about what you store.

## Available Operations

### List memories (`/memory-management list`)

Show all memory files and the current MEMORY.md index.

### Read a memory (`/memory-management read <filename>`)

Read the full content of a specific memory file.

### Write a memory (`/memory-management write <filename>`)

Create or update a memory file. The content should be markdown with YAML frontmatter containing `name` and `description` fields.

**Frontmatter template:**
```markdown
---
name: Short descriptive name
description: One-line summary of the memory
created: 2026-03-18T00:00:00.000Z
createdByTask: <task-id>
updatedByTask: <task-id>
---

Detailed content here...
```

**File naming:** Use descriptive snake_case names (e.g., `no_mocks_in_tests.md`, `auth_rewrite_context.md`).

### Delete a memory (`/memory-management delete <filename>`)

Remove a memory file that is no longer relevant.

### Update index (`/memory-management update-index`)

Update the MEMORY.md index file to reflect current memories. The index should be a concise table of contents with links and brief descriptions.

## When to Create Memories

Create memories when you encounter:
- **User corrections** to your approach (e.g., "don't mock the database")
- **User preferences** for communication style or workflow
- **Project context** that shapes decisions (e.g., "auth rewrite is compliance-driven")
- **External references** to tools, projects, or processes
- **Important discoveries** about the codebase or architecture

## API Reference

All requests use the CoderFlow server API with task authentication:

**Headers:** `X-Task-Id: ${TASK_ID}`, `Content-Type: application/json`
**Base URL:** `${CODERFLOW_SERVER_URL}/api/environment-management`

### List
```bash
curl -s "${CODERFLOW_SERVER_URL}/api/environment-management/memory" \
  -H "X-Task-Id: ${TASK_ID}"
```
Response: `{ files: [...], index: "..." }`

### Read
```bash
curl -s "${CODERFLOW_SERVER_URL}/api/environment-management/memory/{filename}" \
  -H "X-Task-Id: ${TASK_ID}"
```
Response: `{ filename: "...", content: "..." }`

### Write
```bash
curl -s -X PUT "${CODERFLOW_SERVER_URL}/api/environment-management/memory/{filename}" \
  -H "Content-Type: application/json" \
  -H "X-Task-Id: ${TASK_ID}" \
  -d '{ "content": "---\nname: ...\n---\n\n..." }'
```
Response: `{ filename: "...", updated: true }`

### Delete
```bash
curl -s -X DELETE "${CODERFLOW_SERVER_URL}/api/environment-management/memory/{filename}" \
  -H "X-Task-Id: ${TASK_ID}"
```
Response: `{ deleted: true }`

### Update Index
```bash
curl -s -X PUT "${CODERFLOW_SERVER_URL}/api/environment-management/memory-index" \
  -H "Content-Type: application/json" \
  -H "X-Task-Id: ${TASK_ID}" \
  -d '{ "content": "# Memory\n\n..." }'
```
Response: `{ updated: true }`
