for-ais-only/tcedocs/CLI_COMMAND_EXTRACTION_DESIGN.md
This document summarizes the design for extracting Redis CLI commands from code examples and exposing them as metadata to AI agents and documentation systems.
Currently, when AI agents (like myself) encounter code examples in the Redis documentation, we can see the code but lack semantic understanding of which Redis commands are being demonstrated. This is especially problematic for:
Extract Redis CLI commands from {{< clients-example >}} blocks and enrich them with metadata from data/commands_core.json, storing the result in data/examples.json for use by templates and AI systems.
CLI Parser (build/components/cli_parser.py)
Command Enricher (build/components/command_enricher.py)
data/commands_core.jsonIntegration Points
build/local_examples.py: Process local examplesbuild/components/component.py: Process remote examplesEach example in data/examples.json gains an optional cli_commands field:
{
"cli_commands": [
{
"name": "HSET",
"summary": "Creates or modifies the value of a field in a hash.",
"group": "hash",
"complexity": "O(1) for each field/value pair...",
"since": "2.0.0",
"link": "/commands/hset"
}
]
}
SET → SETACL CAT → ACL CAT (check if both tokens form known command)JSON.SET → JSON.SET (detect dot in first token)HSET key field value → HSETMarkdown with CLI example
↓
Parse CLI content (extract commands)
↓
Normalize command names
↓
Look up in commands_core.json
↓
Generate metadata objects
↓
Store in examples.json
↓
Available to Hugo templates and AI systems
Not all examples have CLI content. The cli_commands field is only present when commands are found, keeping JSON clean.
If an example uses HSET multiple times, we list it once. The focus is on which commands are demonstrated, not how many times.
Different languages in the same example set may have different CLI examples. Metadata is language-specific.
Enables templates to create clickable command references and helps AI agents navigate to detailed documentation.
See for-ais-only/tcedocs/SPECIFICATION.md section "CLI Command Extraction" for: