# Crud Ops

> Show ScalarDB CRUD operation patterns — builder syntax for Get, Scan, Insert, Upsert, Update, Delete with examples.

- **Type:** Skill
- **Install:** `agentstack add skill-wfukatsu-nexus-architect-crud-ops`
- **Verified:** Yes — security-reviewed for prompt injection and unsafe behavior
- **Seller:** [wfukatsu](https://agentstack.voostack.com/s/wfukatsu)
- **Installs:** 0
- **Category:** [Agent Skills](https://agentstack.voostack.com/c/agent-skills)
- **Latest version:** 0.1.0
- **License:** MIT
- **Upstream author:** [wfukatsu](https://github.com/wfukatsu)
- **Source:** https://github.com/wfukatsu/nexus-architect/tree/main/skills/crud-ops

## Install

```sh
agentstack add skill-wfukatsu-nexus-architect-crud-ops
```

Requires the [AgentStack CLI](https://agentstack.voostack.com/docs/cli). Works with Claude Code, Cursor, and any MCP-compatible agent.

## About

# /scalardb:crud-ops — ScalarDB CRUD Operations Guide

## Instructions

You are a ScalarDB CRUD operations expert. Show the user how to perform specific CRUD operations with the ScalarDB API.

## Interactive Flow

### Step 1: Determine the operation
Ask: "What operation do you need help with?" if not specified.

Options:
- **Get** — Retrieve a single record by primary key or index
- **Scan** — Retrieve multiple records (partition scan, range scan, scan all, index scan)
- **Insert** — Insert a new record (fails if exists)
- **Upsert** — Insert or update a record
- **Update** — Update an existing record (does nothing if not exists)
- **Delete** — Delete a record
- **Batch** — Execute multiple operations atomically
- **Key construction** — Build single and composite keys

### Step 2: Gather context
Ask about their schema:
- Namespace and table name
- Partition key column(s) and type(s)
- Clustering key column(s) and type(s) if applicable
- Value columns they want to read/write

### Step 3: Generate code
Generate the complete code example including:
- Builder pattern usage
- Key construction
- Result extraction
- Proper exception handling
- Transaction lifecycle (begin, operation, commit, rollback)

## Reference

Read `${CLAUDE_PLUGIN_ROOT}/skills/common/references/api-reference.md` for the complete API reference.
Read `${CLAUDE_PLUGIN_ROOT}/rules/scalardb-crud-patterns.md` for CRUD API coding rules.

## Quick Reference Examples

### Get by Primary Key
```java
Optional result = tx.get(
    Get.newBuilder()
        .namespace("ns").table("tbl")
        .partitionKey(Key.ofInt("id", 1))
        .clusteringKey(Key.ofInt("ck", 2))
        .build());
```

### Get by Index
```java
Optional result = tx.get(
    Get.newBuilder()
        .namespace("ns").table("tbl")
        .indexKey(Key.ofText("order_id", orderId))
        .build());
```

### Scan (Partition)
```java
List results = tx.scan(
    Scan.newBuilder()
        .namespace("ns").table("tbl")
        .partitionKey(Key.ofInt("pk", 1))
        .ordering(Scan.Ordering.desc("ck"))
        .limit(100)
        .build());
```

### Scan (Range)
```java
List results = tx.scan(
    Scan.newBuilder()
        .namespace("ns").table("tbl")
        .partitionKey(Key.ofInt("pk", 1))
        .start(Key.ofInt("ck", 10)).startInclusive(true)
        .end(Key.ofInt("ck", 20)).endInclusive(false)
        .build());
```

### Scan All
```java
List results = tx.scan(
    Scan.newBuilder()
        .namespace("ns").table("tbl")
        .all()
        .limit(100)
        .build());
// Requires: scalar.db.cross_partition_scan.enabled=true
```

### Insert
```java
tx.insert(
    Insert.newBuilder()
        .namespace("ns").table("tbl")
        .partitionKey(Key.ofInt("id", 1))
        .textValue("name", "Alice")
        .intValue("age", 30)
        .build());
```

### Upsert
```java
tx.upsert(
    Upsert.newBuilder()
        .namespace("ns").table("tbl")
        .partitionKey(Key.ofInt("id", 1))
        .textValue("name", "Alice")
        .intValue("age", 31)
        .build());
```

### Update with Condition
```java
tx.update(
    Update.newBuilder()
        .namespace("ns").table("tbl")
        .partitionKey(Key.ofInt("id", 1))
        .intValue("balance", newBalance)
        .condition(ConditionBuilder.updateIf(
            ConditionBuilder.column("balance").isGreaterThanOrEqualToInt(amount)
        ).build())
        .build());
```

### Delete
```java
tx.delete(
    Delete.newBuilder()
        .namespace("ns").table("tbl")
        .partitionKey(Key.ofInt("id", 1))
        .clusteringKey(Key.ofInt("ck", 2))
        .build());
```

### Key Construction (Composite)
```java
Key compositeKey = Key.newBuilder()
    .addInt("col1", 1)
    .addText("col2", "abc")
    .build();
```

### Result Extraction
```java
if (result.isPresent()) {
    Result r = result.get();
    int id = r.getInt("id");           // 0 if NULL
    String name = r.getText("name");   // null if NULL
    boolean isNull = r.isNull("name"); // check NULL
}
```

## Output Format

Provide complete, runnable code examples with proper imports and exception handling. Tailor examples to the user's specific schema.

## Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

- **Author:** [wfukatsu](https://github.com/wfukatsu)
- **Source:** [wfukatsu/nexus-architect](https://github.com/wfukatsu/nexus-architect)
- **License:** MIT

Install and usage instructions live in the source repository linked above.

## Pricing

- **Free** — Free

## Security capabilities

Automated source analysis of v0.1.0 — what this tool can access:

- **Network access:** no
- **Filesystem access:** no
- **Shell / process execution:** no
- **Environment & secrets:** no
- **Dynamic code execution:** no

*"Yes" means the capability is present in the source — more access means more to trust, not that it is unsafe.*


## Versions

- **0.1.0** — security scan: passed — Imported from the upstream source.

## Links

- Listing page: https://agentstack.voostack.com/l/skill-wfukatsu-nexus-architect-crud-ops
- Seller: https://agentstack.voostack.com/s/wfukatsu
- Browse the marketplace: https://agentstack.voostack.com/browse

---
Listed on AgentStack — the marketplace for AI agent skills and MCP servers. Every listing is security-reviewed. Creators keep 70%.
