npm package: @lark-sh/cli
Description: CLI tool for Lark.sh — manage projects, databases, and data from the terminal
Latest version: 0.1.3

# @lark-sh/cli

Command-line tool for [Lark.sh](https://lark.sh) — manage projects, databases, and real-time data from your terminal.

## Install

```bash
npm install -g @lark-sh/cli
```

Or run directly with npx:

```bash
npx @lark-sh/cli <command>
```

## Quick Start

```bash
# Log in via the Lark dashboard
lark login

# Set a default project
lark config set-project my-app

# Read data
lark data get mydb /users/alice

# Write data
lark data set mydb /users/alice '{"name": "Alice", "score": 100}'

# Watch for real-time changes
lark data watch mydb /users
```

## Commands

### Auth

| Command | Description |
|---------|-------------|
| `lark login` | Log in via the Lark dashboard |
| `lark logout` | Log out and clear stored session |
| `lark whoami` | Show the currently logged-in user |

### Configuration

| Command | Description |
|---------|-------------|
| `lark config set-project <id>` | Set the default project |
| `lark config show` | Show current configuration |

### Projects

| Command | Description |
|---------|-------------|
| `lark projects list` | List all projects |
| `lark projects create <name>` | Create a new project |
| `lark projects show [id]` | Show project details |
| `lark projects update [id]` | Update project settings |
| `lark projects delete [id]` | Delete a project |
| `lark projects regenerate-secret [id]` | Regenerate the secret key |

### Databases

| Command | Description |
|---------|-------------|
| `lark databases list` | List databases in a project |
| `lark databases create <id>` | Create a new database |
| `lark databases delete <id>` | Delete a database |

`lark db` is a shorthand alias for `lark databases`.

### Data

| Command | Description |
|---------|-------------|
| `lark data get <db> <path>` | Get data at a path |
| `lark data set <db> <path> <json>` | Set (overwrite) data at a path |
| `lark data update <db> <path> <json>` | Merge data at a path |
| `lark data push <db> <path> <json>` | Push to a list (auto-generated key) |
| `lark data delete <db> <path>` | Delete data at a path |
| `lark data export <db> [path]` | Export data as JSON |
| `lark data import <db> [path]` | Import data from a file |
| `lark data watch <db> <path>` | Stream real-time changes |

Data commands accept JSON inline or from stdin using `-`:

```bash
cat data.json | lark data set mydb /path -
echo '{"score": 200}' | lark data update mydb /users/alice -
```

### Dashboard & Billing

| Command | Description |
|---------|-------------|
| `lark dashboard [id]` | Show metrics (CCU, bandwidth, ops, latency) |
| `lark events [id]` | Show database events |
| `lark billing [id]` | Show billing info |

### Security Rules

| Command | Description |
|---------|-------------|
| `lark rules get [id]` | Get current security rules |
| `lark rules set [id]` | Set rules from a file (`-f`) or stdin |

```bash
lark rules set -f rules.json
cat rules.json | lark rules set
```

## Global Flags

| Flag | Description |
|------|-------------|
| `--json` | Output results as machine-readable JSON |
| `--project <id>` | Override the default project for this command |

## JSON Mode

All commands support `--json` for scripting and automation:

```bash
lark projects list --json
lark data get mydb / --json
lark data watch mydb /messages --json  # outputs NDJSON
```

## Docs

- Documentation: [docs.larksh.com](https://docs.larksh.com) (agent-friendly)
- MCP server: `https://docs.larksh.com/mcp` (provides the `SearchLark` tool)

## License

Apache-2.0