Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .claude-plugin/marketplace.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
},
{
"name": "algolia-cli",
"description": "Skill for managing Algolia indices, records, settings, rules, and synonyms using the Algolia CLI.",
"description": "Use for any hands-on Algolia admin operation: importing/exporting records, backing up indices, managing API keys, editing synonyms, configuring rules, changing settings (facets, searchable attributes), deleting records, copying/migrating indices, or automating Algolia in CI/CD. Contains exact CLI syntax, ndjson format requirements, and flag combinations that are easy to get wrong from memory. Do NOT use for frontend SDK (InstantSearch, React) or Algolia dashboard UI questions β€” see algolia-mcp for read-only search and analytics.",
"source": "./",
"strict": false,
"skills": [
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@

# Node.js
node_modules/

# Skill eval workspaces
*-workspace/
83 changes: 74 additions & 9 deletions skills/algolia-cli/SKILL.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
---
name: algolia-cli
description: >-
Use when managing Algolia search infrastructure from the command line β€”
creating or configuring profiles, searching indices, importing or exporting
records, managing index settings, rules, synonyms, and API keys. Applies
even when the user says "search index," "import data," or "update settings"
without explicitly mentioning the Algolia CLI.
Use this skill whenever a user wants to execute operations against Algolia
indices or accounts β€” deleting records, copying/migrating indices, backing up
data, importing/exporting records, managing API keys, editing synonyms,
configuring rules, changing settings like facets, clearing indices, or
automating Algolia in CI/CD pipelines. The key signal is that the user wants
to *act on* their Algolia data or configuration (server-side / backend /
admin operations), regardless of whether they mention "CLI" or "command
line." If someone names a specific Algolia index and wants to change, move,
query, or manage it, use this skill. Do NOT use for frontend search UI work
(InstantSearch, React components, autocomplete widgets), Algolia dashboard
GUI questions, or evaluating Algolia vs. other providers.
license: MIT
metadata:
author: algolia
Expand All @@ -16,6 +22,20 @@ metadata:

Manage Algolia search infrastructure from the terminal using the `algolia` CLI.

## When to Use This Skill vs. algolia-mcp

| Need | Use |
|------|-----|
| Write/modify data (import, delete, update records) | **algolia-cli** (this skill) |
| Manage configuration (settings, rules, synonyms) | **algolia-cli** (this skill) |
| Admin operations (API keys, profiles, index copy/move) | **algolia-cli** (this skill) |
| Backup/restore indices | **algolia-cli** (this skill) |
| Search queries and view results | **algolia-mcp** |
| Analytics (top searches, click rates, no-results) | **algolia-mcp** |
| Recommendations (related products, trending) | **algolia-mcp** |

**Rule of thumb:** If the user wants to *read or analyze* data β†’ algolia-mcp. If they want to *change, move, or manage* data β†’ algolia-cli.

## Setup

Run `/algolia-cli:setup` to install the CLI and configure a profile, or follow [Getting Started](references/getting-started.md).
Expand Down Expand Up @@ -65,11 +85,11 @@ Run `/algolia-cli:setup` to install the CLI and configure a profile, or follow [
|----------------------------|---------------------------------------------------------------------|
| Browse all records | `algolia objects browse <index>` |
| Browse specific attributes | `algolia objects browse <index> --attributesToRetrieve title,price` |
| Import records from file | `algolia objects import <index> -F data.ndjson` |
| Import from stdin | `cat data.ndjson \| algolia objects import <index> -F -` |
| Import records from file | `algolia objects import <index> -F data.ndjson -y` |
| Import from stdin | `cat data.ndjson \| algolia objects import <index> -F - -y` |
| Delete by IDs | `algolia objects delete <index> --object-ids id1,id2 -y` |
| Delete by filter | `algolia objects delete <index> --filters "type:obsolete" -y` |
| Partial update | `algolia objects update <index> -F updates.ndjson` |
| Partial update | `algolia objects update <index> -F updates.ndjson -y` |

### Settings

Expand Down Expand Up @@ -99,16 +119,61 @@ Run `/algolia-cli:setup` to install the CLI and configure a profile, or follow [
| Delete synonyms by ID | `algolia synonyms delete <index> --synonym-ids id1,id2 -y` |
| Save a single synonym | `algolia synonyms save <index> --id my-syn --synonyms foo,bar` |

## Synonym Type Guide

Choosing the right synonym type matters for search quality:

- **`synonym` (regular/two-way):** All terms are interchangeable. Use when the words truly mean the same thing in both directions.
Example: "sneakers" ↔ "trainers" β€” searching either should find the other.
- **`oneWaySynonym`:** Only the `input` term expands to include the `synonyms`, not the reverse. Use when a short/abbreviated term should match longer/specific terms, but not vice versa.
Example: "TV" β†’ "television", "flat screen" β€” searching "TV" finds "television" results, but searching "television" does NOT return "TV" results.

**Rule of thumb:** If the user says "searching X should *also match* Y", that's one-way (`input: X`, `synonyms: [Y]`). If they say "X and Y should be equivalent/interchangeable", that's two-way.

## Key Conventions

1. **Always use non-interactive mode.** Pass all required flags explicitly so the CLI never prompts for input. Use `-y` (or `--confirm`) to skip confirmation prompts.
1. **Always use non-interactive mode.** Every command that writes, deletes, or modifies data needs `-y` (or `--confirm`) to skip confirmation prompts. This includes `objects import`, `objects delete`, `objects update`, `indices delete/clear/copy/move`, `rules import/delete`, `synonyms import/delete`, and `apikeys delete`. Without `-y`, the CLI will hang waiting for user input.
2. **ndjson format.** `objects browse`, `objects import`, `rules browse/import`, and `synonyms browse/import` use newline-delimited JSON (one JSON object per line), **not** JSON arrays.
3. **Profile flag.** Use `-p <profile>` to target a non-default profile. Omit it to use the default.
4. **Credential precedence.** Environment variables override all other configuration. The resolution order is: **env vars** > **CLI flags** (`--application-id`, `--api-key`) > **profile config file** > **default profile**. Supported env vars: `ALGOLIA_APPLICATION_ID`, `ALGOLIA_API_KEY`, `ALGOLIA_ADMIN_API_KEY`, `ALGOLIA_SEARCH_HOSTS`, `ALGOLIA_CRAWLER_USER_ID`, `ALGOLIA_CRAWLER_API_KEY`. If env vars are set, `--profile`/`-p` is ignored for those credentials.
5. **Wait flag.** Use `-w` (or `--wait`) when subsequent commands depend on the operation completing (e.g., import then search).
6. **Pipe between commands.** Copy data across indices: `algolia objects browse SRC | algolia objects import DST -F -`
7. **JSON output.** Use `--output json` (or `-o json`) when you need machine-readable output.

## Common Workflows

### Migrate records between indices (with field filtering)
```bash
algolia objects browse SOURCE --attributesToRetrieve objectID,title,price \
| algolia objects import DEST -F - -y -w
```

### Full index backup
```bash
algolia objects browse MY_INDEX > my_index_records.ndjson
algolia settings get MY_INDEX > my_index_settings.json
algolia rules browse MY_INDEX > my_index_rules.ndjson
algolia synonyms browse MY_INDEX > my_index_synonyms.ndjson
```
Note: settings use `.json` (standard JSON), everything else uses `.ndjson` (newline-delimited JSON).

### Restore from backup
```bash
algolia objects import MY_INDEX -F my_index_records.ndjson -y -w
algolia settings import MY_INDEX -F my_index_settings.json -y -w
algolia rules import MY_INDEX -F my_index_rules.ndjson -c -y -w
algolia synonyms import MY_INDEX -F my_index_synonyms.ndjson -r -y -w
```

## Direct Invocation

If the skill doesn't trigger automatically, users can invoke it directly:

- **`/algolia-cli`** β€” Load the full skill into context for any Algolia CLI task
- **`/algolia-cli:setup`** β€” Install the CLI and configure a profile

This is useful when the request is brief (e.g., "import my data into Algolia") and the skill might not auto-trigger.

## Reference Docs

- [Getting Started](references/getting-started.md) β€” Installation and profile setup
Expand Down
102 changes: 102 additions & 0 deletions skills/algolia-cli/evals/EVAL_RESULTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
# Algolia CLI Skill β€” Evaluation Results

Evaluation performed on 2026-03-18 using Claude Opus 4.6 (1M context).

## Summary

The skill was evaluated across 3 realistic user scenarios, comparing **with-skill** (Claude reads the skill before responding) vs **without-skill** (Claude relies on general knowledge).

| Metric | Without Skill | With Skill (v1) | With Skill (v2) |
|--------|:------------:|:---------------:|:---------------:|
| **Eval 1** β€” Migrate records | 20% (1/5) | 80% (4/5) | **100% (5/5)** |
| **Eval 2** β€” Synonyms & rules | 50% (3/6) | 67% (4/6) | **100% (6/6)** |
| **Eval 3** β€” Backup & API key | 50% (3/6) | 100% (6/6) | **100% (6/6)** |
| **Average pass rate** | **40%** | **82%** | **100%** |

**v1** = original skill, **v2** = improved skill (current version).

## Eval Details

### Eval 1: Migrate Records Between Indices

**Prompt:** *"I need to export all records from my 'products' index and import them into a new 'products_v2' index, but only keep the title, price, and category fields. After copying, update the search settings to make 'category' a facet."*

| Assertion | Without Skill | With Skill v1 | With Skill v2 |
|-----------|:---:|:---:|:---:|
| Uses `--attributesToRetrieve` for field selection | FAIL | PASS | PASS |
| Pipes browse to import with `-F -` | FAIL | PASS | PASS |
| Uses `--attributesForFaceting` for category facet | PASS | PASS | PASS |
| Includes `-y` flag on write commands | FAIL | FAIL | PASS |
| Uses `-w` flag to sequence import before settings | FAIL | PASS | PASS |

**Key finding:** Without the skill, Claude exported all fields and filtered with `jq` instead of using `--attributesToRetrieve`. It also used intermediate files instead of piping. The v1β†’v2 improvement fixed the missing `-y` flag by adding it to the quick reference tables.

### Eval 2: Synonyms and Rules

**Prompt:** *"Set up synonyms for my 'ecommerce' index β€” 'sneakers' and 'trainers' should be equivalent, and searching 'TV' should also match 'television' and 'flat screen'. Also add a rule that boosts products with 'featured:true' to the top."*

| Assertion | Without Skill | With Skill v1 | With Skill v2 |
|-----------|:---:|:---:|:---:|
| Creates two-way synonym for sneakers/trainers | PASS | PASS | PASS |
| Creates one-way synonym from TV β†’ television, flat screen | PASS | FAIL | PASS |
| Uses correct synonym types (`synonym` vs `oneWaySynonym`) | PASS | FAIL | PASS |
| Creates ndjson file for boost rule | FAIL | PASS | PASS |
| Uses `synonyms save` or `synonyms import` with ndjson | FAIL | PASS | PASS |
| Uses `rules import` with `-F` and `-y` | FAIL | PASS | PASS |

**Key finding:** The baseline actually got synonym directionality right but invented non-existent CLI commands (`algolia rules save --rule`). The v1 skill got commands right but missed the one-way synonym. The v2 Synonym Type Guide with the "rule of thumb" fixed this.

### Eval 3: Full Backup and API Key

**Prompt:** *"I want to back up my entire 'blog_posts' index β€” all records, settings, rules, and synonyms β€” to local files. Then I want to create an API key that only allows search access to that specific index."*

| Assertion | Without Skill | With Skill v1 | With Skill v2 |
|-----------|:---:|:---:|:---:|
| Exports records to `.ndjson` file | FAIL | PASS | PASS |
| Exports settings to `.json` file | PASS | PASS | PASS |
| Exports rules to `.ndjson` file | FAIL | PASS | PASS |
| Exports synonyms to `.ndjson` file | FAIL | PASS | PASS |
| Creates API key with `--acl search --indices blog_posts` | PASS | PASS | PASS |
| Settings use `.json` (not `.ndjson`) | PASS | PASS | PASS |

**Key finding:** Without the skill, Claude used `.json` for all exports. The skill's ndjson format documentation ensures correct file extensions β€” `.ndjson` for records/rules/synonyms, `.json` for settings.

## What the Skill Adds

The biggest areas where the skill outperforms general knowledge:

1. **ndjson format awareness** β€” Knowing which commands use newline-delimited JSON vs standard JSON
2. **Non-interactive flags** β€” Consistently using `-y` to prevent CLI hangs
3. **Piping patterns** β€” Using `-F -` for stdin instead of intermediate files
4. **Synonym type selection** β€” Choosing `oneWaySynonym` vs `synonym` based on user intent
5. **Correct CLI commands** β€” Preventing hallucinated commands like `algolia rules save --rule`
6. **Wait flag sequencing** β€” Using `-w` when operations must complete before the next step

## Trigger Accuracy

Description optimization was performed with 20 eval queries (11 should-trigger, 9 should-not-trigger).

| Metric | Value |
|--------|-------|
| Precision | 100% (never triggers falsely) |
| Recall | ~25% (undertriggers on valid queries) |
| Overall accuracy | 57% |

Low recall is a systemic limitation β€” Claude is confident enough in its Algolia knowledge to attempt tasks directly. Users can invoke `/algolia-cli` explicitly for reliable access.

## Improvements Made (v1 β†’ v2)

1. **Added `-y` flag** to all write commands in quick reference tables
2. **New Synonym Type Guide** with decision rules for `synonym` vs `oneWaySynonym`
3. **Expanded non-interactive convention** listing every command that needs `-y`
4. **New Common Workflows section** (migrate, backup, restore patterns)
5. **Skill differentiation table** (algolia-cli vs algolia-mcp)
6. **Direct invocation guidance** (`/algolia-cli` fallback)
7. **Optimized description** for better triggering accuracy

## Reproducibility

- Model: Claude Opus 4.6 (1M context)
- Eval definitions: `evals/evals.json`
- Date: 2026-03-18
- Each eval was run once per configuration per iteration
46 changes: 46 additions & 0 deletions skills/algolia-cli/evals/evals.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"skill_name": "algolia-cli",
"evals": [
{
"id": 1,
"prompt": "I need to export all records from my 'products' index and import them into a new 'products_v2' index, but only keep the title, price, and category fields. After copying, update the search settings to make 'category' a facet.",
"expected_output": "Commands to browse with specific attributes, pipe to import, and set facet settings",
"files": [],
"expectations": [
"Uses 'algolia objects browse' with --attributesToRetrieve to select only title, price, and category",
"Pipes the browse output to 'algolia objects import' using -F - for stdin",
"Uses 'algolia settings set' with --attributesForFaceting to add 'category' as a facet",
"Includes -y flag on commands that require confirmation",
"Uses -w (wait) flag on import before running the settings command, or chains them appropriately"
]
},
{
"id": 2,
"prompt": "Set up synonyms for my 'ecommerce' index β€” 'sneakers' and 'trainers' should be equivalent, and searching 'TV' should also match 'television' and 'flat screen'. Also add a rule that boosts products with 'featured:true' to the top.",
"expected_output": "Commands or ndjson files to create synonyms and a query rule with boosting",
"files": [],
"expectations": [
"Creates a regular (two-way) synonym linking 'sneakers' and 'trainers'",
"Creates a one-way synonym from 'TV' to 'television' and 'flat screen'",
"Uses correct synonym types: 'synonym' for two-way and 'oneWaySynonym' for one-way",
"Creates an ndjson file for the rule with a condition and consequence that boosts 'featured:true' items",
"Uses 'algolia synonyms save' or 'algolia synonyms import' with proper ndjson format",
"Uses 'algolia rules import' with -F flag and -y for confirmation"
]
},
{
"id": 3,
"prompt": "I want to back up my entire 'blog_posts' index β€” all records, settings, rules, and synonyms β€” to local files. Then I want to create an API key that only allows search access to that specific index.",
"expected_output": "Four backup commands (objects, settings, rules, synonyms) plus an API key creation command",
"files": [],
"expectations": [
"Uses 'algolia objects browse blog_posts' and redirects output to a .ndjson file",
"Uses 'algolia settings get blog_posts' and redirects output to a .json file",
"Uses 'algolia rules browse blog_posts' and redirects output to a .ndjson file",
"Uses 'algolia synonyms browse blog_posts' and redirects output to a .ndjson file",
"Uses 'algolia apikeys create' with --acl search and --indices blog_posts",
"Does NOT use ndjson extension for settings (settings are regular JSON, not ndjson)"
]
}
]
}
2 changes: 2 additions & 0 deletions skills/algolia-mcp/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ metadata:

# Algolia Search & Analytics

> **Need to write/modify data?** Use **algolia-cli** instead β€” it handles imports, exports, backups, settings changes, synonyms, rules, API keys, and all admin operations.
## Connection setup

Use `/algolia-mcp:connect` to configure the MCP client with the Algolia MCP server.
Expand Down
Loading