import_patterns
Bulk-import multiple patterns at once, incrementing existing confidence without lowering. Avoids looping observe() calls. Returns counts of imported, updated, and errors.
Instructions
Bulk-insert many patterns in a single call; faster than looping observe().
Each input row is routed through observe() so existing patterns
have their confidence incremented rather than overwritten, matching
single-call observe() semantics. If an input row specifies a
"confidence" higher than the current stored value, the record is
raised to that target value (never lowered). Rows with missing or
empty "pattern" are skipped.
For importing a CLAUDE.md Markdown file use import_claude_md()
which handles the backtick-wrapped pattern parsing for you. Run
consolidate() after a large import so downstream exports see the
fresh promotions.
Args:
patterns: List of dicts. Each dict requires "pattern" (str key
with category prefix). Optional keys:
- "category": "sequence" | "preference" | "fix_pattern"
| "combo". Defaults to "sequence" if omitted.
- "source": str origin tag (e.g. "codex", "manual").
- "project": str fingerprint. Empty = global.
- "metadata": dict of free-form JSON-serializable data.
- "explain": str human-readable note (truncated at the
store-configured max length).
- "confidence": int starting count. Defaults to 1. If
greater than the current stored confidence for a
pre-existing pattern, the record is raised to this
value.
Returns:
{"imported": int, "updated": int, "errors": int, "hint": str}
"imported" = rows that created a new pattern. "updated" =
rows that reinforced an existing pattern. "errors" = rows
skipped because "pattern" was missing/empty or observe() raised
(count only — see server logs for per-row reasons). "hint"
points to consolidate() as the recommended follow-up.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| patterns | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||