Find Command Specification
Version: 1.0 | Status: DRAFT | Date: 2025-12-18 Task: T376 - Research: Fuzzy task search command for LLM agents Category: Read command (LLM-Agent-First)
Executive Summary
Thefind command provides efficient task discovery for LLM agents, enabling fuzzy search with minimal context output. This directly addresses the context bloat problem: a full list --format json returns 355KB for 352 tasks, while find returns only matching tasks with minimal fields (500 bytes - 2KB typical).
Problem Statement
| Scenario | Current Approach | Context Cost |
|---|---|---|
| Find task by partial title | list --format json | jq | 355KB + parsing |
| Find task by ID prefix | list --format json | grep | 355KB + parsing |
| Fuzzy search for related tasks | list then manual scan | 355KB + LLM reasoning |
| Check if task name exists | list + full scan | 355KB |
Solution: find Command
| Scenario | New Approach | Context Cost | Reduction |
|---|---|---|---|
| Find task by partial title | find "auth" | ~1KB | 99.7% |
| Find task by ID prefix | find --id 37 | ~500B | 99.9% |
| Fuzzy search for related tasks | find "user registration" | ~2KB | 99.4% |
| Check if task name exists | find --exact "Task title" | ~300B | 99.9% |
RFC 2119 Conformance
This specification uses RFC 2119 keywords:- MUST: Absolute requirement
- SHOULD: Recommended but not mandatory
- MAY: Optional
Part 1: Command Definition
Basic Syntax
Arguments
| Argument | Type | Required | Description |
|---|---|---|---|
<query> | string | Yes* | Search query for title/description |
<query> or --id is required
Options
| Option | Short | Type | Default | Description |
|---|---|---|---|---|
--id | -i | string | - | Search by task ID pattern (prefix match) |
--field | string | title,description | Fields to search: title, description, labels, notes, all | |
--status | -s | string | - | Filter by status |
--limit | -n | int | 10 | Maximum results to return |
--threshold | -t | float | 0.3 | Minimum match score (0-1) |
--exact | -e | bool | false | Exact match instead of fuzzy |
--include-archive | bool | false | Search archived tasks too | |
--format | -f | string | auto | Output format: text, json, jsonl |
--quiet | -q | bool | false | Suppress non-essential output |
--verbose | -v | bool | false | Include full task objects in output |
Exit Codes
| Code | Constant | Description |
|---|---|---|
| 0 | EXIT_SUCCESS | Matches found |
| 2 | EXIT_INVALID_INPUT | Invalid query or options |
| 100 | EXIT_NO_DATA | No matches found (not an error) |
Part 2: Search Modes
2.1 Fuzzy Title/Description Search (Default)
Searches task titles and descriptions using substring matching with relevance scoring.- Case-insensitive substring match
- Word boundary bonus (matching whole word scores higher)
- Title match scores higher than description match
- Multiple query terms use AND logic
2.2 ID Pattern Search
Searches task IDs by prefix, suffix, or contains.2.3 Exact Match Search
Returns only exact title matches (useful for duplicate checking).2.4 Multi-Field Search
Part 3: Output Format (LLM-Agent-First)
3.1 JSON Output (Default for Non-TTY)
MUST follow LLM-AGENT-FIRST-SPEC envelope:3.2 Minimal Match Object
For context efficiency, match objects are minimal by default:| Field | Type | Included | Description |
|---|---|---|---|
id | string | Always | Task ID |
title | string | Always | Task title |
status | string | Always | Task status |
priority | string | Always | Task priority |
score | float | Always | Match relevance (0-1) |
matched_in | array | Always | Fields where match was found |
phase | string | If present | Task phase |
labels | array | If --verbose | Task labels |
description | string | If --verbose | Full description |
3.3 Verbose Output
With--verbose, include full task objects:
3.4 Text Output (Interactive TTY)
Part 4: Use Cases for LLM Agents
4.1 Task Discovery Before Update
4.2 Dependency Resolution
4.3 Duplicate Checking Before Add
4.4 ID Lookup with Partial Memory
4.5 Label-Based Task Discovery
Part 5: Implementation Requirements
5.1 Foundation Libraries (MUST)
Per LLM-AGENT-FIRST-SPEC:5.2 TTY-Aware Format Resolution (MUST)
5.3 JSON Output Requirements (MUST)
- Include
$schemafield - Include complete
_metaenvelope - Include
successboolean - Use
output_error()for errors
5.4 Performance Requirements
| Metric | Requirement |
|---|---|
| Search time (1000 tasks) | < 100ms |
| Memory usage | O(n) where n = result count |
| JSON output size (10 matches) | < 5KB |
5.5 Scoring Algorithm
Part 6: CLI Integration
6.1 Command Registration
Add toinstall.sh CMD_MAP:
6.2 Aliases
6.3 Help Integration
Part 7: Error Handling
7.1 Error Responses
7.2 No Matches Response
Part 8: Testing Requirements
8.1 Unit Tests
8.2 Performance Tests
Part 9: Comparison with Existing Commands
| Feature | list | exists | show | find |
|---|---|---|---|---|
| Returns all tasks | Yes | No | No | No |
| Fuzzy search | No | No | No | Yes |
| ID prefix search | No | Exact only | Exact only | Yes |
| Minimal output | No | Binary | Full task | Yes |
| Match scoring | No | No | No | Yes |
| Context efficient | No | Yes | Moderate | Yes |
Use Case Decision Tree
Appendix A: Alternative Names Considered
| Name | Pros | Cons | Decision |
|---|---|---|---|
find | Familiar (Unix), clear purpose | Might conflict with shell find | SELECTED |
search | Clear, no conflicts | Longer to type | Alias |
lookup | Clear | Less common | Rejected |
query | Database-like | Too generic | Rejected |
match | Describes behavior | Less intuitive | Rejected |
Appendix B: Context Savings Analysis
Based on this project (352 tasks, 357KB todo.json):| Operation | list Context | find Context | Savings |
|---|---|---|---|
| Find 1 task | 355KB | ~0.5KB | 99.9% |
| Find 5 tasks | 355KB | ~1.5KB | 99.6% |
| Find 10 tasks | 355KB | ~3KB | 99.1% |
| ID lookup | 355KB | ~0.3KB | 99.9% |
- Current: 355KB * 100 = 35.5MB/day = ~$10.65/day
- With find: 3KB * 100 = 300KB/day = ~$0.09/day
- Savings: 3,850/year
Specification v1.0 - Research Complete Task T376 - Research: Fuzzy task search command for LLM agents Created: 2025-12-18
