/beanis:beanisfrom beanis
Generates correct code for Beanis, the async Pydantic ODM for Redis. Handles documents, indexes, CRUD, vector search on Redis 8 vector sets, and agent memory.
Ships in beanis. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Beanis stores Pydantic models as Redis hashes and keeps secondary indexes. It is NOT Beanie (MongoDB): there is no query builder, no to_list(), find_one(), .sort(), .limit() and no Model.field > x expressions. Use only the API below.
from redis.asyncio import Redis
from beanis import Document, Indexed, IndexedField, VectorField, GeoPoint, init_beanis
redis = Redis(decode_responses=True) # decode_responses=True is required
await init_beanis(database=redis, document_models=[Product])
Requirements: Python 3.9+, Redis 5+; Redis 8.0+ for VectorField and Memory (vector sets). init_beanis raises if a model has vector fields and the server lacks VADD. Run beanis doctor to check a server.
from typing import List, Optional
from typing_extensions import Annotated
class Product(Document):
name: str
price: Indexed(float) # number -> sorted set (ranges)
category: Annotated[str, IndexedField()] # scalar -> set (exact match)
location: Indexed(GeoPoint) # geo index (not Optional[...])
embedding: Annotated[List[float], VectorField(dimensions=384)] # Redis 8 vector set
class Settings:
key_prefix = "Product" # hash key: Product:<id>
Indexed is a function: Indexed(float), never Indexed[float].register_type(cls, encoder=, decoder=) for others.doc = await Product(name="Tea", price=3.0, category="drinks", embedding=vec).insert() # insert(ttl=seconds) optional
await Product.get(doc.id) # None if missing
await Product.get_many(ids); await Product.exists(id); await Product.count()
await Product.insert_many(docs)
await doc.save() # upsert; moves index entries if indexed values changed
await doc.update(price=4.0) # partial update, indexes kept in sync
await doc.get_field("price"); await doc.set_field("price", 5.0); await doc.increment_field("stock", -1)
await doc.set_ttl(60); await doc.get_ttl(); await doc.persist()
await doc.delete_self(); await Product.delete(id); await Product.delete_many(ids); await Product.delete_all()
await Product.find(category="drinks") # exact
await Product.find(price__gte=10, price__lte=50) # __gte __lte __gt __lt
await Product.find(price=12.0) # exact number
await Product.find(category="drinks", price__lt=5) # ANDed
await Product.all(skip=0, limit=20) # by insertion time
A filter on a non-indexed field raises ValueError. Sort or slice the returned list in Python. Geo: IndexManager.find_by_geo_radius(...) from beanis.odm.indexes (see docs/tutorial/geo-spatial.md).
hits = await Product.vector_search(query_vec, k=5, filter='.category == "drinks"', min_score=0.0)
for doc, score in hits: ... # best first; score = cosine similarity in [0, 1]
filter uses vector-set filter syntax over the document's short scalar fields: .field == "x", .price > 10, and, or, not. HNSW, cosine only, int8 quantization by default (VectorField(quantization="NOQUANT") for float32). Product.find_by_vector_similarity(...) returns (id, score) pairs without loading documents.
from beanis import Memory
from beanis.memory import fastembed_embedder, memory_from_env
memory = Memory(redis, embed=fastembed_embedder(), namespace="my-agent") # or: memory_from_env()
rec = await memory.remember("User prefers metric units", user_id="u1", kind="preference", ttl=None)
hits = await memory.recall("which units?", user_id="u1", k=5, min_score=0.0) # [(MemoryRecord, score)]
await memory.recent(user_id="u1", limit=10)
await memory.forget(rec.id)
Near-duplicates (similarity >= 0.95 in the same scope) replace the old memory. All memories share one vector set, so every writer must use the same embedding model.
If tools named remember, recall, forget and recent from the beanis memory server are available:
recall before answering questions that may depend on earlier conversations, project decisions or user preferences.remember when the user states a durable fact, preference or decision, or when you settle something worth knowing next session (a convention, a gotcha, where something lives). Write one self-contained sentence; set kind to preference, decision, fact or note.forget outdated memories by id when the user corrects them.beanis doctor
beanis memory remember "text" [--user U] [--session S] [--kind K] [--ttl N]
beanis memory recall "query" [-k 5] [--user U] [--kind K] [--min-score 0.3]
beanis memory recent [--limit 10]
beanis memory forget <id>
beanis context # newest memories as plain text (SessionStart hook)
beanis mcp # stdio MCP server, same as beanis-mcp
Environment: REDIS_URL, BEANIS_MEMORY_NAMESPACE (auto = one namespace per git project, from $CLAUDE_PROJECT_DIR or the working directory), BEANIS_EMBED_MODEL.
What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
npx claudepluginhub andreim14/beanis --plugin beanis