> ## Documentation Index
> Fetch the complete documentation index at: https://docs.coconut.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# nut context

> Manage context documents

# `nut context`

Manage context documents (role, agents, team, memory) for your Coconut instance.

```bash theme={null}
nut context [command]
```

## Overview

Context documents provide essential information to AI skills about the role they should play, the agents available to them, the team they are collaborating with, and any memory that should persist across sessions. These documents help skills make better decisions and produce more relevant results.

<Note>
  `nut context` manages context documents in the current local workspace. To read context from a remote peer Coconut through the Coconut Dashboard, use [`nut coconut context`](/cli/coconut).
</Note>

### Context Types

* **role** - Role definitions and expectations for AI skills
* **agents** - Agent definitions and capabilities available in the instance
* **team** - Team structure, members, and collaboration conventions
* **memory** - Long-lived notes and memory to carry across sessions

***

## `nut context get`

Read a context document.

```bash theme={null}
nut context get <type> [options]
```

**Arguments:**

* `type` - Context type (`role`, `agents`, `team`, or `memory`)

**Options:**

* `--json` - Output as JSON

**Examples:**

```bash theme={null}
# Read role definition
nut context get role

# Read agents as JSON
nut context get agents --json

# Read team context
nut context get team

# Read memory
nut context get memory
```

***

## `nut context update`

Replace the entire content of a context document.

```bash theme={null}
nut context update <type> [options]
```

**Arguments:**

* `type` - Context type to update

**Options:**

* `--file <path>` - Path to file containing new content
* `--content <text>` - Direct content to set

**Examples:**

```bash theme={null}
# Update with direct content
nut context update role --content "# Role Definition\n\nAI skills should focus on code quality and testing..."

# Update agents from file
nut context update agents --file ./agents.md

# Replace team document
nut context update team --file ./docs/team.md
```

<Note>
  Using `update` replaces the entire document. Use `append` to add content without replacing existing text.
</Note>

***

## `nut context append`

Append content to a context document.

```bash theme={null}
nut context append <type> [content] [options]
```

**Arguments:**

* `type` - Context type to append to
* `content` - Text to append (optional if using `--file`)

**Options:**

* `--file <path>` - Path to file to append

**Examples:**

```bash theme={null}
# Append text directly
nut context append team "## New Section\n\nContent here..."

# Append from file
nut context append memory --file ./additional-notes.md

# Add role clarifications
nut context append role "## Additional Guidelines\n\n- Always write tests\n- Follow the style guide"
```

<Tip>
  Appending is useful for incrementally building up context without having to re-specify everything.
</Tip>

***

## `nut context replace`

Find and replace text in a context document.

```bash theme={null}
nut context replace <type> --old <text> --new <text>
```

**Arguments:**

* `type` - Context type to modify

**Options:**

* `--old <text>` - Text to find (required)
* `--new <text>` - Replacement text (required)

**Examples:**

```bash theme={null}
# Update role description
nut context replace role --old "old text" --new "new text"

# Fix terminology in agents
nut context replace agents --old "assistant" --new "agent"

# Update a team reference
nut context replace team --old "code reviewer" --new "senior code reviewer"
```

***

## Context Document Examples

### Role Context

```markdown theme={null}
# AI Skill Roles

## General Guidelines
- Write clean, maintainable code
- Include comprehensive tests
- Follow existing code patterns
- Document complex logic

## Code Review Focus
- Security vulnerabilities
- Performance implications
- Error handling
- Test coverage

## Communication
- Explain changes clearly
- Ask for clarification when needed
- Suggest improvements proactively
```

### Agents Context

```markdown theme={null}
# Agents

## Planner
Breaks high-level goals into ordered, reviewable tasks.

## Implementer
Executes tasks, writes code, and opens proposals for review.

## Reviewer
Audits proposals for correctness, security, and style before merge.
```

### Team Context

```markdown theme={null}
# Team

## Members
- Engineering: builds and maintains services
- Design: owns UX and visual design
- Product: prioritizes roadmap and requirements

## Working Agreements
- Changes land via reviewed proposals
- Prefer small, incremental PRs
- Document architectural decisions
```

### Memory Context

```markdown theme={null}
# Memory

## Recent Decisions
- Chose PostgreSQL over MySQL for JSONB support
- Standardized on Next.js App Router

## Ongoing Considerations
- Evaluating queue options for background jobs
- Monitoring bundle size on the marketing site
```

***

## Best Practices

<AccordionGroup>
  <Accordion title="Keep context up to date">
    Regularly update context documents as your project evolves. Outdated information can lead to AI skills making incorrect assumptions.
  </Accordion>

  <Accordion title="Be specific and detailed">
    The more detail you provide, the better AI skills can understand your project and make appropriate decisions. Include coding standards, architectural patterns, and specific requirements.
  </Accordion>

  <Accordion title="Use consistent formatting">
    Structure your context documents with clear headings and sections. Markdown formatting makes documents easier to read and parse.
  </Accordion>

  <Accordion title="Start simple, iterate">
    Begin with basic context and expand over time. You don't need perfect, comprehensive context on day one—add details as you discover what information skills need most.
  </Accordion>
</AccordionGroup>

***

## Context Workflow

<Steps>
  <Step title="Define skill roles">
    ```bash theme={null}
    nut context update role --content "# Role Definition\n\nAI skills should..."
    ```
  </Step>

  <Step title="Describe available agents">
    ```bash theme={null}
    nut context update agents --file ./AGENTS.md
    ```
  </Step>

  <Step title="Add team context">
    ```bash theme={null}
    nut context update team --file ./TEAM.md
    ```
  </Step>

  <Step title="Refine incrementally">
    ```bash theme={null}
    nut context append memory "## New Notes\n\n..."
    ```
  </Step>

  <Step title="Review and update">
    ```bash theme={null}
    nut context get role
    nut context replace role --old "outdated info" --new "current info"
    ```
  </Step>
</Steps>
