Patterns
Automatic pattern extraction from landing reports for cross-session knowledge reuse.
Patterns
Patterns are a beta feature. The API surface and behavior may change in future releases.
Patterns are extracted automatically from landing reports after a successful kavi land. They capture what was done, what files were touched, what commands were used, and relevant metadata -- then persist across sessions so that future missions benefit from prior experience.
How Patterns Work
When a mission lands successfully, Kavi analyzes the landing report and extracts a pattern record. This pattern encodes the shape of the work: the title and summary, the file paths that were changed, the commands that were run, and tags derived from the codebase context.
When a new mission starts, Kavi searches the pattern library for the top 3 matching patterns and promotes them into the mission's brain as "Pattern: ..." entries. This gives agents context about how similar work was done before, including which files to look at and which commands to run.
Pattern Storage
Patterns are stored in a JSON file at the repository root:
This file persists across sessions and is meant to be committed to version control so the entire team benefits from accumulated patterns.
PatternEntry Interface
The following fields make up a pattern entry:
| Field | Type | Description |
|---|---|---|
id | string | Unique pattern identifier |
sourceRepoRoot | string | Absolute path to the repository root where the pattern was extracted |
missionId | string | null | ID of the mission that produced this pattern |
reportId | string | null | ID of the landing report that produced this pattern |
title | string | Short title summarizing the pattern |
summary | string | Detailed description of the work that was done |
prompt | string | null | The original mission prompt, if available |
tags | string[] | Tags for categorization and matching |
examplePaths | string[] | File paths that were changed as part of this pattern |
commands | string[] | Commands that were used (test runners, build scripts, etc.) |
createdAt | string | ISO timestamp of creation |
updatedAt | string | ISO timestamp of last update |
Deduplication
Pattern deduplication uses a fingerprint computed from:
- Normalized title (lowercased, trimmed)
- Sorted tags
- Repository root path
If a pattern with the same fingerprint already exists, Kavi merges the new data into the existing record:
summary,prompt,reportId, andmissionIdare updated to the latest valuestags,examplePaths, andcommandsare unioned (no duplicates)updatedAtis refreshed
This keeps the pattern library compact while accumulating knowledge over time.
Tag Extraction
Tags are automatically extracted from multiple sources:
- File extensions -- e.g.,
.ts,.tsx,.go,.rsbecome tags liketypescript,react,go,rust - Path segments -- directory names from changed file paths (e.g.,
src/api/producesapi) - Mission context -- tokens from the mission title and prompt that match known categories
Tag extraction is capped at 20 tags per pattern to keep entries focused.
Command Detection
Kavi detects commands from two sources:
- package.json scripts --
test,build,lint, and other scripts defined in the project'spackage.json - Common test/build commands --
npm test,go test,cargo test,pytest,npm run build, and other standard commands detected from the repository structure
Detected commands are stored in the pattern so that future missions working on similar code know which validation commands to run.
CLI Commands
# List all patterns, or search with a query
kavi patterns
kavi patterns "api endpoint"kavi patterns displays the stored pattern library with titles, tags, and example paths. With a query argument, it filters patterns by relevance.