jpskill.com
💼 ビジネス コミュニティ

reading-logseq-data

Logseqのデータベースグラフから、HTTP APIやCLIを通じてページ、ブロック、プロパティを取得したり、Datalogクエリを実行したり、コンテンツ検索やバックリンク抽出など、Logseqに関する様々なデータ操作を支援するSkill。

📜 元の英語説明(参考)

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.

🇯🇵 日本人クリエイター向け解説

一言でいうと

Logseqのデータベースグラフから、HTTP APIやCLIを通じてページ、ブロック、プロパティを取得したり、Datalogクエリを実行したり、コンテンツ検索やバックリンク抽出など、Logseqに関する様々なデータ操作を支援するSkill。

※ jpskill.com 編集部が日本のビジネス現場向けに補足した解説です。Skill本体の挙動とは独立した参考情報です。

⚡ おすすめ: コマンド1行でインストール(60秒)

下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。

🍎 Mac / 🐧 Linux
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o reading-logseq-data.zip https://jpskill.com/download/17704.zip && unzip -o reading-logseq-data.zip && rm reading-logseq-data.zip
🪟 Windows (PowerShell)
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/17704.zip -OutFile "$d\reading-logseq-data.zip"; Expand-Archive "$d\reading-logseq-data.zip" -DestinationPath $d -Force; ri "$d\reading-logseq-data.zip"

完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。

💾 手動でダウンロードしたい(コマンドが難しい人向け)
  1. 1. 下の青いボタンを押して reading-logseq-data.zip をダウンロード
  2. 2. ZIPファイルをダブルクリックで解凍 → reading-logseq-data フォルダができる
  3. 3. そのフォルダを C:\Users\あなたの名前\.claude\skills\(Win)または ~/.claude/skills/(Mac)へ移動
  4. 4. Claude Code を再起動

⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。

🎯 このSkillでできること

下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。

📦 インストール方法 (3ステップ)

  1. 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
  2. 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
  3. 3. 展開してできたフォルダを、ホームフォルダの .claude/skills/ に置く
    • · macOS / Linux: ~/.claude/skills/
    • · Windows: %USERPROFILE%\.claude\skills\

Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。

詳しい使い方ガイドを見る →
最終更新
2026-05-18
取得日時
2026-05-18
同梱ファイル
3

📖 Skill本文(日本語訳)

※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。

Logseqデータの読み取り

この Skill の使用時

この Skill は、以下の場合に自動的に起動します。

  • ユーザーが自分の Logseq グラフからページまたはブロックを読み取りたい場合
  • Logseq エンティティからプロパティまたはメタデータを取得する場合
  • グラフに対して Datalog クエリを実行する場合
  • Logseq でコンテンツを検索する場合
  • バックリンクまたは参照を検索する場合
  • ユーザーが "get from logseq"、"fetch page"、"query logseq" などと発言した場合

クライアントライブラリ: 統一された API については、{baseDir}/scripts/logseq-client.py を参照してください。

利用可能な操作

操作 説明
get_page(title) ページの内容とプロパティを取得します
get_block(uuid) 子を持つブロックを取得します
search(query) グラフ全体で全文検索を実行します
datalog_query(query) Datalog クエリを実行します
list_pages() すべてのページをリスト表示します
get_backlinks(title) このページにリンクしているページを検索します
get_graph_info() 現在のグラフのメタデータを取得します

簡単な例

ページの取得

from logseq_client import LogseqClient

client = LogseqClient()
page = client.get_page("My Page")
print(f"Title: {page['title']}")
print(f"Properties: {page['properties']}")

Datalog クエリの実行

# 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")

コンテンツの検索

# "project" の言及を検索
results = client.search("project")
for block in results:
    print(f"Found in: {block['page']}")
    print(f"Content: {block['content'][:100]}...")

Datalog クエリのパターン

すべてのページを検索

[: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]]

集計

;; 著者ごとの書籍数をカウント
[:find ?author (count ?b)
 :where
 [?b :block/tags ?t]
 [?t :block/title "Book"]
 [?b :user.property/author ?author]]

クライアントライブラリの使用

初期化

from logseq_client import LogseqClient

# バックエンドの自動検出
client = LogseqClient()

# 特定のバックエンドを強制
client = LogseqClient(backend="http")

# カスタム URL/トークン
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")

バッチ処理

# 複数のページを効率的に取得
pages = ["Page1", "Page2", "Page3"]
results = [client.get_page(p) for p in pages]

# または、単一のクエリを使用
query = '''
    [:find (pull ?p [*])
     :in $ [?titles ...]
     :where
     [?p :block/title ?titles]]
'''
results = client.datalog_query(query, [pages])

パフォーマンスのヒント

  1. 具体的なクエリを使用する - 必要な以上のものを取得しないでください
  2. pull 構文を優先する - (pull ?e [:needed :fields]) vs [*]
  3. 選択的な句を最初に置く - クエリの早い段階でフィルタリングする
  4. パラメータを使用する - :in 句を介して値を渡す
  5. 可能な場合はバッチ処理を行う - 1 つのクエリで複数のアイテムを処理する

CLI フォールバック

HTTP API が利用できない場合、クライアントは CLI にフォールバックします。

# CLI モード (HTTP が失敗した場合に自動)
client = LogseqClient(backend="cli", graph_path="/path/to/graph")

# クエリは同じように機能します
results = client.datalog_query("[:find ?title :where [?p :block/title ?title]]")

出力形式

Raw (デフォルト)

API から Python の dict/list を直接返します。

Normalized

# 正規化された出力を取得
page = client.get_page("My Page", normalize=True)
# 戻り値: {"title": "...", "uuid": "...", "properties": {...}, "blocks": [...]}

参考資料

  • すべての操作については、{baseDir}/references/read-operations.md を参照してください
  • クエリパターンについては、{baseDir}/templates/query-template.edn を参照してください
📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開

Reading Logseq Data

When to Use This Skill

This skill auto-invokes when:

  • User wants to read pages or blocks from their Logseq graph
  • Fetching properties or metadata from Logseq entities
  • Executing Datalog queries against the graph
  • Searching for content in Logseq
  • Finding backlinks or references
  • User mentions "get from logseq", "fetch page", "query logseq"

Client Library: See {baseDir}/scripts/logseq-client.py for the unified API.

Available Operations

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

Quick Examples

Get a Page

from logseq_client import LogseqClient

client = LogseqClient()
page = client.get_page("My Page")
print(f"Title: {page['title']}")
print(f"Properties: {page['properties']}")

Execute Datalog Query

# 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 Content

# 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]}...")

Datalog Query Patterns

Find All Pages

[:find (pull ?p [:block/title])
 :where
 [?p :block/tags ?t]
 [?t :db/ident :logseq.class/Page]]

Find Blocks with Tag

[:find (pull ?b [*])
 :where
 [?b :block/tags ?t]
 [?t :block/title "Book"]]

Find by Property

[:find ?title ?author
 :where
 [?b :block/title ?title]
 [?b :user.property/author ?author]
 [?b :block/tags ?t]
 [?t :block/title "Book"]]

Find Tasks by Status

[: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 Backlinks

[:find (pull ?b [:block/title {:block/page [:block/title]}])
 :in $ ?page-title
 :where
 [?p :block/title ?page-title]
 [?b :block/refs ?p]]

Aggregations

;; Count books per author
[:find ?author (count ?b)
 :where
 [?b :block/tags ?t]
 [?t :block/title "Book"]
 [?b :user.property/author ?author]]

Using the Client Library

Initialization

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"
)

Error Handling

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")

Batch Operations

# 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])

Performance Tips

  1. Use specific queries - Don't fetch more than needed
  2. Prefer pull syntax - (pull ?e [:needed :fields]) vs [*]
  3. Put selective clauses first - Filter early in query
  4. Use parameters - Pass values via :in clause
  5. Batch when possible - Multiple items in one query

CLI Fallback

If 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]]")

Output Formats

Raw (default)

Returns Python dicts/lists directly from API.

Normalized

# Get normalized output
page = client.get_page("My Page", normalize=True)
# Returns: {"title": "...", "uuid": "...", "properties": {...}, "blocks": [...]}

Reference Materials

  • See {baseDir}/references/read-operations.md for all operations
  • See {baseDir}/templates/query-template.edn for query patterns

同梱ファイル

※ ZIPに含まれるファイル一覧。`SKILL.md` 本体に加え、参考資料・サンプル・スクリプトが入っている場合があります。