Expert in reading data from Logseq DB graphs via HTTP API or CLI. Auto-invokes when users want to fetch pages, blocks, or properties from Logseq, execute Datalog queries against their graph, search content, or retrieve backlinks and relationships. Provides the logseq-client library for operations.
/plugin marketplace add C0ntr0lledCha0s/claude-code-plugin-automations/plugin install logseq-expert@claude-code-plugin-automationsThis skill is limited to using the following tools:
references/read-operations.mdscripts/logseq-client.pytemplates/query-template.ednThis skill auto-invokes when:
Client Library: See {baseDir}/scripts/logseq-client.py for the unified API.
| Operation | Description |
|---|---|
get_page(title) | Get page content and properties |
get_block(uuid) | Get block with children |
search(query) | Full-text search across graph |
datalog_query(query) | Execute Datalog query |
list_pages() | List all pages |
get_backlinks(title) | Find pages linking to this one |
get_graph_info() | Get current graph metadata |
from logseq_client import LogseqClient
client = LogseqClient()
page = client.get_page("My Page")
print(f"Title: {page['title']}")
print(f"Properties: {page['properties']}")
# Find all books with rating >= 4
results = client.datalog_query('''
[:find (pull ?b [:block/title :user.property/rating])
:where
[?b :block/tags ?t]
[?t :block/title "Book"]
[?b :user.property/rating ?r]
[(>= ?r 4)]]
''')
for book in results:
print(f"{book['block/title']}: {book['user.property/rating']} stars")
# Search for mentions of "project"
results = client.search("project")
for block in results:
print(f"Found in: {block['page']}")
print(f"Content: {block['content'][:100]}...")
[:find (pull ?p [:block/title])
:where
[?p :block/tags ?t]
[?t :db/ident :logseq.class/Page]]
[:find (pull ?b [*])
:where
[?b :block/tags ?t]
[?t :block/title "Book"]]
[:find ?title ?author
:where
[?b :block/title ?title]
[?b :user.property/author ?author]
[?b :block/tags ?t]
[?t :block/title "Book"]]
[:find (pull ?t [:block/title :logseq.property/status])
:where
[?t :block/tags ?tag]
[?tag :db/ident :logseq.class/Task]
[?t :logseq.property/status ?s]
[?s :block/title "In Progress"]]
[:find (pull ?b [:block/title {:block/page [:block/title]}])
:in $ ?page-title
:where
[?p :block/title ?page-title]
[?b :block/refs ?p]]
;; Count books per author
[:find ?author (count ?b)
:where
[?b :block/tags ?t]
[?t :block/title "Book"]
[?b :user.property/author ?author]]
from logseq_client import LogseqClient
# Auto-detect backend
client = LogseqClient()
# Force specific backend
client = LogseqClient(backend="http")
# Custom URL/token
client = LogseqClient(
url="http://localhost:12315",
token="your-token"
)
try:
page = client.get_page("Nonexistent Page")
except client.NotFoundError:
print("Page doesn't exist")
except client.ConnectionError:
print("Cannot connect to Logseq")
except client.AuthError:
print("Invalid token")
# Get multiple pages efficiently
pages = ["Page1", "Page2", "Page3"]
results = [client.get_page(p) for p in pages]
# Or use a single query
query = '''
[:find (pull ?p [*])
:in $ [?titles ...]
:where
[?p :block/title ?titles]]
'''
results = client.datalog_query(query, [pages])
(pull ?e [:needed :fields]) vs [*]:in clauseIf HTTP API unavailable, the client falls back to CLI:
# CLI mode (automatic if HTTP fails)
client = LogseqClient(backend="cli", graph_path="/path/to/graph")
# Query still works the same way
results = client.datalog_query("[:find ?title :where [?p :block/title ?title]]")
Returns Python dicts/lists directly from API.
# Get normalized output
page = client.get_page("My Page", normalize=True)
# Returns: {"title": "...", "uuid": "...", "properties": {...}, "blocks": [...]}
{baseDir}/references/read-operations.md for all operations{baseDir}/templates/query-template.edn for query patternsThis skill should be used when the user asks to "create a slash command", "add a command", "write a custom command", "define command arguments", "use command frontmatter", "organize commands", "create command with file references", "interactive command", "use AskUserQuestion in command", or needs guidance on slash command structure, YAML frontmatter fields, dynamic arguments, bash execution in commands, user interaction patterns, or command development best practices for Claude Code.
This skill should be used when the user asks to "create an agent", "add an agent", "write a subagent", "agent frontmatter", "when to use description", "agent examples", "agent tools", "agent colors", "autonomous agent", or needs guidance on agent structure, system prompts, triggering conditions, or agent development best practices for Claude Code plugins.
This skill should be used when the user asks to "create a hook", "add a PreToolUse/PostToolUse/Stop hook", "validate tool use", "implement prompt-based hooks", "use ${CLAUDE_PLUGIN_ROOT}", "set up event-driven automation", "block dangerous commands", or mentions hook events (PreToolUse, PostToolUse, Stop, SubagentStop, SessionStart, SessionEnd, UserPromptSubmit, PreCompact, Notification). Provides comprehensive guidance for creating and implementing Claude Code plugin hooks with focus on advanced prompt-based hooks API.