agnesoft/agdb/agdb-query
Claude Code and agent skill by agnesoft/agdb
- community
Checking that the SKILL.md file is still in the repository.
Build, review, and explain agdb queries accurately. Use this skill when writing QueryBuilder chains, converting between search/select/insert/remove, reasoning about where_ conditions, or debugging query logic and result semantics in agdb.
Install
npx vskill@latest install agnesoft/agdb/agdb-querySKILL.md
agdb Query Skill
Use this skill when working with agdb query construction and behavior, especially:
- QueryBuilder chains in Rust
search+where_conditions and modifiers- Converting query intent into correct
insert/remove/select/search - Understanding
QueryResultandDbTypemapping - Debugging query logic errors vs data errors
- Value amendment operations (
insert().amend(),remove().amend(),insert().amend_or(), etc.)
Primary sources in this repository:
agdb/src/query.rsagdb/src/query_builder.rsagdb/src/query_builder/*agdb/src/query/*agdb_web/content/docs/03.references/01.queries.md
Mental model
QueryBuilderbuilds typed query objects.- Query objects are executed by
Db::exec(immutable) orDb::exec_mut(mutable). - Every query returns
Result<QueryResult, DbError>. QueryResultcontains:
result: numeric aggregate (count or similar)elements: element payloads (ids and/or values depending on query, always present, can be empty)
QueryResult::ids()extracts just theDbIdof every element — useful for chaining.QueryResultimplementsTryInto<Vec<T>>andTryInto<T>forDbType/DbElementtypes.
Execution rules
- Use
execfor immutable queries:select,search. - Use
exec_mutfor mutable queries:insert,remove. - All query execution is transactional under the hood.
- Explicit transactions (
transaction/transaction_mut) are for grouping multiple queries. - In explicit transactions, the closure receives a
Transaction/TransactionMutwith the sameexec/exec_mutmethods.
QueryBuilder cheat sheet
Immutable (use with exec)
Mutable (use with exec_mut)
Value amendments
Amendment operations modify existing values in place rather than replacing them:
`amend` (add) behavior by type:
| Type | Behavior | |
|---|---|---|
I64, U64 | Saturating addition | |
F64 | Floating-point addition | |
String | Concatenation | |
Bytes | Byte vector extension | |
Vec* | Extend with elements (or push single scalar) |
`remove().amend()` behavior by type:
| Type | Behavior | |
|---|---|---|
I64, U64 | Saturating subtraction | |
F64 | Floating-point subtraction | |
String | Remove first occurrence of substring | |
Bytes | Not supported (returns error) | |
Vec* | Remove first matching element per item |
Builder behavior that is easy to miss
QueryBuilder::search()defaults to breadth-first search.QueryBuilder::select().search()is shorthand for selecting values via a nested search query.QueryBuilder::insert().values(...).search()is shorthand for using search result ids as insert targets.QueryBuilder::insert().nodes().ids(...)enables insert-or-update semantics:- empty ids result: insert
- non-empty ids result: update existing nodes
QueryBuilder::insert().edges().ids(...)does the same for edges (updates values of found edge ids).QueryBuilder::select().element::<T>()setslimit = 1and usesT::db_keys().- If
T::db_element_id()isSome, typedselect/searchadds adb_element_idfilter automatically. QueryBuilder::insert().element(x)andelements(&xs)only work with types implementingDbElement(not justDbType).search().depth_first()changes traversal to DFS — more efficient when searching for a single item.
Conditions (where_) guidance
Condition chains compile into QueryCondition items with:
- logic:
AndorOr - modifier:
None,Not,Beyond,NotBeyond - data: node/edge/ids/key-value/distance/etc.
Most useful primitives
Logic operators
Important: or() passes if either side evaluates to true. and() passes only if both sides evaluate to true.
Modifiers
not(): negates selection result of the next condition.beyond(): controls traversal only; continue past an element only if condition passes.not_beyond(): controls traversal only; stop past an element if condition passes.
Important: beyond() / not_beyond() do not directly select/reject elements by themselves. Pair them with normal selection conditions when needed.
Convenience helpers
Distance shorthands — avoid manually constructing CountComparison:
Value comparison shorthands — avoid manually constructing Comparison:
Edge count shorthands — avoid manually constructing CountComparison:
Typed element filter:
where_().element::<T>():- uses
db_element_idfilter if available - otherwise falls back to keys-based condition
Known caveat
where_().ids(...)does not support nested search ids in this condition context; a search passed there is ignored.
Search semantics
from(x): forward traversal (starting from x)to(x): reverse traversal following incoming edges (starting from x)from(x).to(y): path search (A*) going from x to yto(y).from(x): reverse path search — follows incoming edges, can be significantly faster when the destination has fewer incoming edges than the origin has outgoingelements(): full element scan (can be expensive)index("key").value(v): indexed lookup — supportslimit,offset,order_by, andwhere_()conditions just like graph searches
Search supports breadth-first (BFS, default) and depth-first (DFS, depth_first()) traversal order, can be selected in the builder query (QueryBuilder::search().depth_first()...). This changes order in which the elements are visited and therefore the order of results and how beyond/not_beyond conditions are applied.
Use limit and offset for large traversals. For elements() queries, always consider limit first.
You can also order results with order_by:
Query type selection rubric
- Need ids only by traversal/filtering:
search - Need values/properties:
select(optionally with nestedsearch) - Need create/update:
insert - Need delete aliases/elements/index/values:
remove
Common pitfalls and corrections
- Pitfall: using
execwith mutable query.
- Fix: use
exec_mut.
- Pitfall:
insert().values(Multi)count does not match target ids.
- Fix: align lengths or switch to
values_uniform.
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 93 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryChecking.github/skills/agdb-query/SKILL.md
Popularity
- Repository stars
- 137
- Repository forks
- 7
- 7-day trend score
- 25
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/agnesoft/agdb/agdb-query)