Skill: woodcoal/affine (version 1.0.0)

--- name: affine-cli description: Command-line tool for managing Affine documents, tags, folders, collections, files, databases, comments, journals and workspaces. Supports both cloud (app.affine.pro) and self-hosted deployments. homepage: https://github.com/woodcoal/affine-cli tags: [affine, document-management, cli, markdown, notes, wiki, database, collaboration, self-hosted] metadata: openclaw: requires: bins: [node, npm] env: AFFINE_API_TOKEN: required AFFINE_BASE_URL: "optional — defaults to https://app.affine.pro" AFFINE_WORKSPACE_ID: optional note: Configuration loads from: env > local .env > ~/.affine-cli/affine-cli.env --- # Affine CLI Command-line tool for managing Affine documents and workspaces. Works with both cloud and self-hosted Affine instances. ## Installation Check First, verify affine-cli is installed: ```bash which affine-cli || npm list -g affine-cli ``` If not installed, install globally: ```bash npm install -g affine-cli ``` Or run directly with npx: ```bash npx affine-cli <command> ``` ## When to Use - Managing documents, tags, folders, collections - Working with databases, comments, journals - Batch operations on Affine workspace - Automating document workflows ## Quick Start ```bash # 1. Login (get token from https://app.affine.pro/settings/tokens) affine-cli auth login --token YOUR_TOKEN # 2. Check status affine-cli auth status # 3. List workspaces affine-cli workspace list # 4. List documents affine-cli doc list ``` **Self-hosted:** ```bash affine-cli auth login --url https://your-affine.example.com --token YOUR_TOKEN ``` ## Command Overview | Module | Commands | |--------|----------| | **auth** | login, logout, status | | **workspace** | list | | **doc** | list, all, info, create, delete, copy, update, search, replace, append, publish, unpublish | | **tags** | list, create, add, remove, delete, info | | **folder** | all, list, create, delete, update, clear, add, move, remove | | **collection** | list, info, create, update, delete, add, remove | | **file** | upload, delete, clean | | **database** | list, columns, query, create, insert, update, delete, remove | | **comments** | list, create, update, delete, resolve | | **journal** | list, create, info, append, update | ## Common Examples ### Daily Journal ```bash # Create today's journal affine-cli journal create # Append to today's journal affine-cli journal append --content "# Morning\n- Reviewed tasks\n- Team standup" # Append to specific date affine-cli journal append --date 2025-04-10 --content "# Notes\nMeeting with team" # View journal affine-cli journal info --date 2025-04-10 # List recent journals affine-cli journal list --count 7 ``` ### Documents ```bash # Find a document by title affine-cli doc search -q "meeting notes" # Create from file (README.md, etc.) affine-cli doc create -t "Q2 Planning" -c "@planning.md" # Create with tags affine-cli doc create -t "Project Alpha" -c "# Project\nDetails" --tags "work,important" --icon "📁" # View document content affine-cli doc info -i DOC_ID --content markdown # Add content to document affine-cli doc append -i DOC_ID --content "\n\n## Update\nNew content here" # Search with tag filter affine-cli doc search -q "budget" --tag finance ``` ### Tags ```bash # Create tag affine-cli tags create --name "review" # Add tag to document affine-cli tags add -d DOC_ID --tag review # List all tags affine-cli tags list # Find documents with tag affine-cli tags info --tag review ``` ### Folders ```bash # Create folder affine-cli folder create --name "Projects" # List root folders affine-cli folder all # List folder contents affine-cli folder list --id FOLDER_ID # Move document to folder affine-cli folder move --id FOLDER_ID -d DOC_ID ``` ### Databases ```bash # List databases in a doc affine-cli database list --doc DOC_ID # Query data (filters) affine-cli database query --doc DOC_ID --id DB_ID -q '[{"column":"Status","operator":"eq","value":"Done"}]' # Insert new row affine-cli database insert --doc DOC_ID --id DB_ID --content '[{"Task":"Review PR","Status":"Todo"}]' # Update rows affine-cli database update --doc DOC_ID --id DB_ID --values '{"Status":"Done"}' -q '[{"column":"Task","operator":"contains","value":"Review"}]' ``` ## Configuration **Priority**: env vars > local .env > global config **Files:** - Global: `~/.affine-cli/affine-cli.env` - Local: `<project>/.env` **Environment variables:** - `AFFINE_API_TOKEN` - Required, get from Settings → Tokens - `AFFINE_BASE_URL` - Server URL (default: https://app.affine.pro) - `AFFINE_WORKSPACE_ID` - Default workspace ## Reference Files - [commands/basics.md](commands/basics.md) - Auth, workspace, documents - [commands/tags-folders.md](commands/tags-folders.md) - Tags and folders - [commands/collections.md](commands/collections.md) - Collections - [commands/files.md](commands/files.md) - File attachments - [commands/databases.md](commands/databases.md) - Database operations - [commands/comments.md](commands/comments.md) - Comments - [commands/journals.md](commands/journals.md) - Journals ## Support - GitHub: https://github.com/woodcoal/affine-cli - Issues: https://github.com/woodcoal/affine-cli/issues - Docs: https://deepwiki.com/toeverything/AFFiNE

path: _meta.json
content: ownerId: affine-cli
slug: affine-cli
version: 1.0.0
publishedAt: 1713000000000

path: commands/basics.md
content: # Basic Commands

Auth, workspace, and document operations.

---

## Auth Module

### login

Login with your Affine account.

```bash
affine-cli auth login [options]
```

| Option | Short | Required | Description |
|--------|-------|----------|-------------|
| --url | -u | No | Server URL. Default: `https://app.affine.pro` |
| --token | -t | No | API token. If not provided, interactive login |
| --workspace | -w | No | Workspace ID to use as default |
| --local | - | No | Save to local `.env` instead of global config |
| --force | -f | No | Overwrite existing config without prompts |

**Examples:**
```bash
# Login to cloud
affine-cli auth login --token your_api_token

# Login to self-hosted instance
affine-cli auth login --url https://affine.yourcompany.com --token your_token

# Save to local project
affine-cli auth login --token your_token --local
```

### logout

Remove saved credentials.

```bash
affine-cli auth logout [--local]
```

| Option | Required | Description |
|--------|----------|-------------|
| --local | No | Remove local `.env` instead of global config |

### status

Check current login status.

```bash
affine-cli auth status [--json]
```

| Option | Short | Required | Description |
|--------|-------|----------|-------------|
| --json | -j | No | Output as JSON format |

---

## Workspace Module

### list

List all accessible workspaces.

```bash
affine-cli workspace list [options]
```

| Option | Short | Required | Description |
|--------|-------|----------|-------------|
| --format | -f | No | Output format: `text` (default) or `json` |

---

## Document Module

### list

List documents in workspace.

```bash
affine-cli doc list [options]
```

| Option | Short | Required | Description |
|--------|-------|----------|-------------|
| --workspace | -w | No | Workspace ID. Uses config default if not specified |
| --count | -c | No | Number of results to return (default: 20) |
| --tag | -t | No | Filter by tag name |

### all

List all documents including deleted ones.

```bash
affine-cli doc all [options]
```

| Option | Short | Required | Description |
|--------|-------|----------|-------------|
| --workspace | -w | No | Workspace ID |
| --count | -c | No | Page size (default: 50) |
| --skip | -s | No | Number of documents to skip |
| --after | -a | No | Cursor for pagination |

### info

Get document details.

```bash
affine-cli doc info [options]
```

| Option | Short | Required | Description |
|--------|-------|----------|-------------|
| --id | -i | **Yes** | Document ID |
| --workspace | -w | No | Workspace ID |
| --content | -c | No | Content output mode: `markdown` (default), `raw`, or `hidden` |

### create

Create a new document.

```bash
affine-cli doc create [options]
```

| Option | Short | Required | Description |
|--------|-------|----------|-------------|
| --title | -t | **Yes** | Document title |
| --content | -c | No | Markdown content. Prefix `@` for file path (e.g., `@readme.md`) |
| --folder | -f | No | Parent folder ID |
| --tags | - | No | Comma-separated tags (e.g., `work,important`) |
| --icon | -i | No | Emoji icon (e.g., `📝`, `📁`, `💡`) |
| --workspace | -w | No | Workspace ID |

**Examples:**
```bash
# Simple document
affine-cli doc create -t "My Note" -c "# Hello\n\nThis is content"

# From file
affine-cli doc create -t "Meeting Notes" -c "@meeting.md"

# With tags and icon
affine-cli doc create -t "Project Alpha" --tags "work,project" --icon "📁"
```

### search

Search documents by keyword.

```bash
affine-cli doc search [options]
```

| Option | Short | Required | Description |
|--------|-------|----------|-------------|
| --query | -q | **Yes** | Search keyword |
| --workspace | -w | No | Workspace ID |
| --count | -c | No | Number of results (default: 20) |
| --match-mode | -m | No | Match mode: `substring` (default), `prefix`, `suffix`, `exact` |
| --tag | -t | No | Filter by tag name |

### delete

Delete a document.

```bash
affine-cli doc delete [options]
```

| Option | Short | Required | Description |
|--------|-------|----------|-------------|
| --id | -i | **Yes** | Document ID |
| --workspace | -w | No | Workspace ID |

### copy

Copy a document.

```bash
affine-cli doc copy [options]
```

| Option | Short | Required | Description |
|--------|-------|----------|-------------|
| --id | -i | **Yes** | Source document ID |
| --title | -t | No | New document title. Uses source title if not specified |
| --parent | -p | No | Parent document ID (to create as child) |
| --folder | -f | No | Target folder ID |
| --workspace | -w | No | Workspace ID |

### update

Update document properties.

```bash
affine-cli doc update [options]
```

| Option | Short | Required | Description |
|--------|-------|----------|-------------|
| --id | -i | **Yes** | Document ID |
| --title | -t | No | New title |
| --parent | -p | No | New parent document ID. Use empty to remove |
| --folder | -f | No | Target folder ID |
| --icon | -i | No | New emoji icon |
| --workspace | -w | No | Workspace ID |

### replace

Replace text in document content.

```bash
affine-cli doc replace [options]
```

| Option | Short | Required | Description |
|--------|-------|----------|-------------|
| --id | -i | **Yes** | Document ID |
| --search | -s | **Yes** | Text to find |
| --replace | -r | **Yes** | Replacement text |
| --workspace | -w | No | Workspace ID |
| --match-all | -a | No | Replace all occurrences (default: true) |
| --preview | -p | No | Show result without applying changes |

### append

Append content to document.

```bash
affine-cli doc append [options]
```

| Option | Short | Required | Description |
|--------|-------|----------|-------------|
| --id | -i | **Yes** | Document ID |
| --content | -c | **Yes** | Content to append. Prefix `@` for file path |
| --workspace | -w | No | Workspace ID |

### publish

Publish document for public access.

```bash
affine-cli doc publish [options]
```

| Option | Short | Required | Description |
|--------|-------|----------|-------------|
| --id | -i | **Yes** | Document ID |
| --mode | -m | No | Mode: `Page` or `Edgeless` |
| --workspace | -w | No | Workspace ID |

### unpublish

Remove public access from document.

```bash
affine-cli doc unpublish [options]
```

| Option | Short | Required | Description |
|--------|-------|----------|-------------|
| --id | -i | **Yes** | Document ID |
| --workspace | -w | No | Workspace ID |

path: commands/collections.md
content: # Collections

---

## Collection Module

### list

List all collections (favorites) in workspace.

```bash
affine-cli collection list [options]
```

| Option | Short | Required | Description |
|--------|-------|----------|-------------|
| --workspace | -w | No | Workspace ID |

### info

List documents in a collection.

```bash
affine-cli collection info [options]
```

| Option | Short | Required | Description |
|--------|-------|----------|-------------|
| --id | -i | **Yes** | Collection ID |
| --workspace | -w | No | Workspace ID |

### create

Create a new collection.

```bash
affine-cli collection create [options]
```

| Option | Short | Required | Description |
|--------|-------|----------|-------------|
| --name | -n | **Yes** | Collection name |
| --workspace | -w | No | Workspace ID |

### update

Rename a collection.

```bash
affine-cli collection update [options]
```

| Option | Short | Required | Description |
|--------|-------|----------|-------------|
| --id | -i | **Yes** | Collection ID |
| --name | -n | **Yes** | New name |
| --workspace | -w | No | Workspace ID |

### delete

Delete a collection.

```bash
affine-cli collection delete [options]
```

| Option | Short | Required | Description |
|--------|-------|----------|-------------|
| --id | -i | **Yes** | Collection ID |
| --workspace | -w | No | Workspace ID |

### add

Add document to collection.

```bash
affine-cli collection add [options]
```

| Option | Short | Required | Description |
|--------|-------|----------|-------------|
| --id | -i | **Yes** | Collection ID |
| --doc | -d | **Yes** | Document ID to add |
| --workspace | -w | No | Workspace ID |

### remove

Remove document from collection.

```bash
affine-cli collection remove [options]
```

| Option | Short | Required | Description |
|--------|-------|----------|-------------|
| --id | -i | **Yes** | Collection ID |
| --doc | -d | **Yes** | Document ID to remove |
| --workspace | -w | No | Workspace ID |

path: commands/comments.md
content: # Comments

---

## Comments Module

### list

List comments on a document.

```bash
affine-cli comments list [options]
```

| Option | Short | Required | Description |
|--------|-------|----------|-------------|
| --doc-id | -d | **Yes** | Document ID |
| --workspace | -w | No | Workspace ID |
| --first | -n | No | Number of results (default: 20) |
| --offset | -o | No | Offset for pagination |
| --full | -f | No | Return full comment data |

### create

Create a comment on a document.

```bash
affine-cli comments create [options]
```

| Option | Short | Required | Description |
|--------|-------|----------|-------------|
| --doc-id | -d | **Yes** | Document ID |
| --content | -c | **Yes** | Comment text |
| --workspace | -w | No | Workspace ID |
| --selection | -s | No | Text being commented on (will auto-link) |
| --doc-title | - | No | Document title |
| --doc-mode | -m | No | Document mode: `page` or `edgeless` |

### update

Update comment text.

```bash
affine-cli comments update [options]
```

| Option | Short | Required | Description |
|--------|-------|----------|-------------|
| --id | -i | **Yes** | Comment ID |
| --content | -c | **Yes** | New comment text |

### delete

Delete a comment.

```bash
affine-cli comments delete [options]
```

| Option | Short | Required | Description |
|--------|-------|----------|-------------|
| --id | -i | **Yes** | Comment ID |
| --workspace | -w | No | Workspace ID |
| --doc-id | -d | No | Document ID (auto-detected if not provided) |

### resolve

Mark comment as resolved/unresolved.

```bash
affine-cli comments resolve [options]
```

| Option | Short | Required | Description |
|--------|-------|----------|-------------|
| --id | -i | **Yes** | Comment ID |
| --resolved | -r | **Yes** | `true` or `false` |

path: commands/databases.md
content: # Databases

---

## Database Module

### list

List databases in a document.

```bash
affine-cli database list [options]
```

| Option | Short | Required | Description |
|--------|-------|----------|-------------|
| --doc | -d | **Yes** | Document ID containing the database |
| --workspace | -w | No | Workspace ID |

### columns

Get column definitions of a database.

```bash
affine-cli database columns [options]
```

| Option | Short | Required | Description |
|--------|-------|----------|-------------|
| --doc | -d | **Yes** | Document ID |
| --id | -i | **Yes** | Database block ID |
| --workspace | -w | No | Workspace ID |

### query

Query rows from a database.

```bash
affine-cli database query [options]
```

| Option | Short | Required | Description |
|--------|-------|----------|-------------|
| --doc | -d | **Yes** | Document ID |
| --id | -i | **Yes** | Database block ID |
| --rows | -r | No | Comma-separated row IDs to return |
| --columns | -c | No | Comma-separated column names to return |
| --query | -q | No | Filter conditions in JSON format |
| --full | -f | No | Return full row data |
| --workspace | -w | No | Workspace ID |

**Filter format:**
```json
[{"column":"ColumnName","operator":"eq","value":"Value"}]
```

**Operators:**
- `eq` - Equal
- `neq` - Not equal
- `contains` - Contains substring
- `startswith` - Starts with
- `endswith` - Ends with
- `gt` - Greater than
- `gte` - Greater than or equal
- `lt` - Less than
- `lte` - Less than or equal

**Multiple filters (AND logic):**
```json
[{"column":"Status","operator":"eq","value":"Done"},{"column":"Priority","operator":"eq","value":"High"}]
```

**With OR logic:**
```json
{"mode":"or","filters":[{"column":"Status","operator":"eq","value":"Done"},{"column":"Status","operator":"eq","value":"In Progress"}]}
```

**Examples:**
```bash
# Simple filter
affine-cli database query --doc DOC_ID --id DB_ID -q '[{"column":"Status","operator":"eq","value":"Done"}]'

# Multiple columns
affine-cli database query --doc DOC_ID --id DB_ID --columns "Title,Status,Priority"

# Full output
affine-cli database query --doc DOC_ID --id DB_ID --full
```

### create

Create a new database.

```bash
affine-cli database create [options]
```

| Option | Short | Required | Description |
|--------|-------|----------|-------------|
| --content | -c | **Yes** | Data in JSON format |
| --doc | -d | No | Document ID (creates new doc if not specified) |
| --title | -t | No | Database title (and new document title) |
| --view-mode | -m | No | View mode: `table` (default) or `kanban` |
| --workspace | -w | No | Workspace ID |

**Content formats:**

Simple array:
```json
[{"Title":"Task 1","Status":"Todo"},{"Title":"Task 2","Status":"Done"}]
```

With column definitions:
```json
{"title":"My Database","columns":[{"name":"Title","type":"text"},{"name":"Status","type":"select","options":["Todo","Done"]},"data":[{"Title":"Task 1","Status":"Todo"}]}
```

**Examples:**
```bash
# Create in new document
affine-cli database create --title "Task Tracker" --content '[{"Task":"Review PR","Status":"Todo"}]'

# Create in existing document
affine-cli database create --doc DOC_ID --content '[{"Task":"New Task","Status":"Todo"}]'

# From file
affine-cli database create --content "@tasks.json"
```

### insert

Insert rows into database.

```bash
affine-cli database insert [options]
```

| Option | Short | Required | Description |
|--------|-------|----------|-------------|
| --doc | -d | **Yes** | Document ID |
| --id | -i | **Yes** | Database block ID |
| --content | -c | **Yes** | Row data in JSON format |
| --workspace | -w | No | Workspace ID |

**Content format:**
```json
[{"Title":"Task","Status":"Todo"}]
```

Or single row:
```json
{"Title":"Task","Status":"Todo"}
```

**Examples:**
```bash
# Single row
affine-cli database insert --doc DOC_ID --id DB_ID --content '{"Task":"New","Status":"Todo"}'

# Multiple rows
affine-cli database insert --doc DOC_ID --id DB_ID --content '[{"Task":"A","Status":"Todo"},{"Task":"B","Status":"Done"}]'
```

### update

Update rows in database.

```bash
affine-cli database update [options]
```

| Option | Short | Required | Description |
|--------|-------|----------|-------------|
| --doc | -d | **Yes** | Document ID |
| --id | -i | **Yes** | Database block ID |
| --values | -v | **Yes** | Updated cell values in JSON |
| --row | -r | No* | Row block ID |
| --query | -q | No* | Filter conditions |
| --workspace | -w | No | Workspace ID |

*Either `--row` or `--query` is required.

**Examples:**
```bash
# Update specific row
affine-cli database update --doc DOC_ID --id DB_ID --values '{"Status":"Done"}' --row ROW_ID

# Update filtered rows
affine-cli database update --doc DOC_ID --id DB_ID --values '{"Status":"Done"}' -q '[{"column":"Status","operator":"eq","value":"Todo"}]'
```

### delete (database)

Delete entire database.

```bash
affine-cli database delete [options]
```

| Option | Short | Required | Description |
|--------|-------|----------|-------------|
| --doc | -d | **Yes** | Document ID |
| --id | -i | **Yes** | Database block ID |
| --workspace | -w | No | Workspace ID |

### remove (row)

Delete rows from database.

```bash
affine-cli database remove [options]
```

| Option | Short | Required | Description |
|--------|-------|----------|-------------|
| --doc | -d | **Yes** | Document ID |
| --id | -i | **Yes** | Database block ID |
| --row | -r | No* | Row block ID |
| --query | -q | No* | Filter conditions |
| --workspace | -w | No | Workspace ID |

*Either `--row` or `--query` is required.

**Examples:**
```bash
# Remove specific row
affine-cli database remove --doc DOC_ID --id DB_ID --row ROW_ID

# Remove filtered rows
affine-cli database remove --doc DOC_ID --id DB_ID -q '[{"column":"Status","operator":"eq","value":"Cancelled"}]'

path: commands/files.md
content: # File Attachments

---

## File Module

### upload

Upload a file attachment.

```bash
affine-cli file upload [options]
```

| Option | Short | Required | Description |
|--------|-------|----------|-------------|
| --file | -f | No* | File path to upload. Either --file or --content required |
| --content | -c | No* | Base64 or plain text content |
| --filename | -n | No | File name. Uses filename from --file or "content" |
| --content-type | - | No | MIME type (e.g., `image/png`, `application/pdf`) |
| --workspace | -w | No | Workspace ID |

*Either `--file` or `--content` is required.

**Examples:**
```bash
# Upload from file
affine-cli file upload --file ./document.pdf

# Upload with custom name
affine-cli file upload --file ./image.png --filename "photo.png"

# Upload text content
affine-cli file upload --content "Hello world" --filename "hello.txt" --content-type "text/plain"
```

### delete

Delete a file attachment.

```bash
affine-cli file delete [options]
```

| Option | Short | Required | Description |
|--------|-------|----------|-------------|
| --id | -i | **Yes** | Blob ID (attachment ID) |
| --permanently | -p | No | Permanently delete. Default: soft delete |
| --workspace | -w | No | Workspace ID |

### clean

Clean up soft-deleted files to free storage space.

```bash
affine-cli file clean [options]
```

| Option | Short | Required | Description |
|--------|-------|----------|-------------|
| --workspace | -w | No | Workspace ID |

path: commands/journals.md
content: # Journals

---

## Journal Module

### list

List journals in workspace.

```bash
affine-cli journal list [options]
```

| Option | Short | Required | Description |
|--------|-------|----------|-------------|
| --workspace | -w | No | Workspace ID |
| --count | -c | No | Number of journals to return (default: 20) |

### create

Create a new journal entry.

```bash
affine-cli journal create [options]
```

| Option | Short | Required | Description |
|--------|-------|----------|-------------|
| --date | -d | No | Date in YYYY-MM-DD format. Default: today |
| --content | -c | No | Journal content. Prefix `@` for file path |
| --icon | -i | No | Emoji icon (e.g., `📝`, `💭`, `🎯`) |
| --workspace | -w | No | Workspace ID |

**Examples:**
```bash
# Create today's journal
affine-cli journal create

# Create for specific date
affine-cli journal create --date 2025-04-10

# Create with content
affine-cli journal create --content "# Morning\n- Team standup\n- Code review"

# From file
affine-cli journal create --content "@journal.md"

# With icon
affine-cli journal create --icon "💭"
```

### info

Get journal details.

```bash
affine-cli journal info [options]
```

| Option | Short | Required | Description |
|--------|-------|----------|-------------|
| --id | -i | No* | Document ID |
| --date | -d | No* | Date in YYYY-MM-DD format |
| --workspace | -w | No | Workspace ID |

*Either `--id` or `--date` is required.

**Examples:**
```bash
# By date
affine-cli journal info --date 2025-04-10

# By ID
affine-cli journal info -i DOC_ID
```

### append

Append content to journal.

```bash
affine-cli journal append [options]
```

| Option | Short | Required | Description |
|--------|-------|----------|-------------|
| --id | -i | No* | Document ID |
| --date | -d | No* | Date in YYYY-MM-DD format |
| --content | -c | **Yes** | Content to append. Prefix `@` for file path |
| --workspace | -w | No | Workspace ID |

*Either `--id` or `--date` is required.

**Examples:**
```bash
# Append to today
affine-cli journal append --content "# Evening\n- Completed tasks"

# Append to specific date
affine-cli journal append --date 2025-04-10 --content "# Notes\nMeeting summary"

# Append from file
affine-cli journal append --date 2025-04-10 --content "@notes.md"
```

### update

Update journal content (replaces entire content).

```bash
affine-cli journal update [options]
```

| Option | Short | Required | Description |
|--------|-------|----------|-------------|
| --id | -i | No* | Document ID |
| --date | -d | No* | Date in YYYY-MM-DD format |
| --content | -c | No | New content |
| --icon | -i | No | New emoji icon |
| --workspace | -w | No | Workspace ID |

*Either `--id` or `--date` is required.

**Examples:**
```bash
# Update by date
affine-cli journal update --date 2025-04-10 --content "# Updated content"

# Update icon
affine-cli journal update --date 2025-04-10 --icon "💡"

# Update from file
affine-cli journal update --date 2025-04-10 --content "@new-content.md"
```

path: commands/tags-folders.md
content: # Tags and Folders

---

## Tags Module

### list

List all tags in workspace.

```bash
affine-cli tags list [options]
```

| Option | Short | Required | Description |
|--------|-------|----------|-------------|
| --workspace | -w | No | Workspace ID |

### create

Create a new tag.

```bash
affine-cli tags create [options]
```

| Option | Short | Required | Description |
|--------|-------|----------|-------------|
| --name | -n | **Yes** | Tag name |
| --color | -c | No | Color hex code (e.g., `#3B82F6`) |
| --workspace | -w | No | Workspace ID |

**Examples:**
```bash
# Simple tag
affine-cli tags create --name important

# With color
affine-cli tags create --name urgent --color #EF4444
```

### add

Add tag to document.

```bash
affine-cli tags add [options]
```

| Option | Short | Required | Description |
|--------|-------|----------|-------------|
| --doc | -d | **Yes** | Document ID |
| --tag | -t | **Yes** | Tag name |
| --workspace | -w | No | Workspace ID |

### remove

Remove tag from document.

```bash
affine-cli tags remove [options]
```

| Option | Short | Required | Description |
|--------|-------|----------|-------------|
| --doc | -d | **Yes** | Document ID |
| --tag | -t | **Yes** | Tag name |
| --workspace | -w | No | Workspace ID |

### delete

Delete a tag entirely.

```bash
affine-cli tags delete [options]
```

| Option | Short | Required | Description |
|--------|-------|----------|-------------|
| --tag | -t | **Yes** | Tag name |
| --workspace | -w | No | Workspace ID |

### info

List documents with a specific tag.

```bash
affine-cli tags info [options]
```

| Option | Short | Required | Description |
|--------|-------|----------|-------------|
| --tag | -t | **Yes** | Tag name |
| --workspace | -w | No | Workspace ID |
| --ignore-case | -i | No | Case-insensitive search |

---

## Folder Module

### all

List all folders in workspace.

```bash
affine-cli folder all [options]
```

| Option | Short | Required | Description |
|--------|-------|----------|-------------|
| --workspace | -w | No | Workspace ID |

### list

List contents of a folder.

```bash
affine-cli folder list [options]
```

| Option | Short | Required | Description |
|--------|-------|----------|-------------|
| --id | -i | **Yes** | Folder ID |
| --folder | -f | No | Return only subfolders (not documents) |
| --workspace | -w | No | Workspace ID |

### create

Create a new folder.

```bash
affine-cli folder create [options]
```

| Option | Short | Required | Description |
|--------|-------|----------|-------------|
| --name | -n | **Yes** | Folder name |
| --parent | -p | No | Parent folder ID |
| --index | - | No | Sort order index |
| --workspace | -w | No | Workspace ID |

**Examples:**
```bash
# Create root folder
affine-cli folder create --name Projects

# Create subfolder
affine-cli folder create --name "2025" --parent PARENT_FOLDER_ID
```

### delete

Delete a folder.

```bash
affine-cli folder delete [options]
```

| Option | Short | Required | Description |
|--------|-------|----------|-------------|
| --id | -i | **Yes** | Folder ID |
| --workspace | -w | No | Workspace ID |

### update

Update folder properties.

```bash
affine-cli folder update [options]
```

| Option | Short | Required | Description |
|--------|-------|----------|-------------|
| --id | -i | **Yes** | Folder ID |
| --name | -n | No | New folder name |
| --parent | -p | No | New parent folder ID. Use empty to move to root |
| --index | - | No | Sort order index |
| --workspace | -w | No | Workspace ID |

### clear

Remove all empty folders.

```bash
affine-cli folder clear [options]
```

| Option | Short | Required | Description |
|--------|-------|----------|-------------|
| --workspace | -w | No | Workspace ID |

### add

Add document to folder.

```bash
affine-cli folder add [options]
```

| Option | Short | Required | Description |
|--------|-------|----------|-------------|
| --id | -i | **Yes** | Folder ID |
| --doc | -d | **Yes** | Document ID to add |
| --index | - | No | Sort order index |
| --workspace | -w | No | Workspace ID |

### move

Move document from another folder to this folder.

```bash
affine-cli folder move [options]
```

| Option | Short | Required | Description |
|--------|-------|----------|-------------|
| --id | -i | **Yes** | Target folder ID |
| --doc | -d | **Yes** | Document ID to move |
| --workspace | -w | No | Workspace ID |

### remove

Remove document from folder (does not delete the document).

```bash
affine-cli folder remove [options]
```

| Option | Short | Required | Description |
|--------|-------|----------|-------------|
| --id | -i | **Yes** | Folder ID |
| --doc | -d | **Yes** | Document ID to remove |
| --workspace | -w | No | Workspace ID |

Security scan verdicts — ClawScan: clean | static analysis: clean | VirusTotal: clean | SkillSpector: suspicious (HIGH)