mcpField
O
obsidian-bases

obsidian-bases

github.com/jackjin1997生産性1336 回インストール19 週間前に更新
リポジトリ

obsidian-bases について

skills 対応エージェントが、ビュー、フィルター、数式などを含む有効な Obsidian Bases ファイルを作成・編集するためのスキルです。Obsidian の保管庫でノートの動的なビューを定義する用途に向いています。

主な機能

  1. 01.base ファイルの作成と編集
  2. 02テーブル、カード、リストビューの設定
  3. 03全体およびビュー別フィルター
  4. 04数式とプロパティの利用
  5. 05集計計算の設定

活用シーン

  1. 01タスク管理ビューの作成
  2. 02読書リストの整理
  3. 03プロジェクトノートの集約
  4. 04デイリーノートの索引作成

インストール

コマンドをコピーしてターミナルで実行します。

$npx skills add https://github.com/jackjin1997/clawforge --skill obsidian-bases

インストール後、Claude Code で/obsidian-basesを入力して読み込まれたか確認します。

詳細

Obsidian Bases スキル

このスキルを使うと、スキル互換のエージェントが、ビュー、フィルター、数式、および関連するすべての設定を含む、有効な Obsidian Bases(.base)ファイルを作成および編集できます。

概要

Obsidian Bases は、Obsidian の保管庫内のノートを動的に表示するための、YAML ベースのファイルです。Base ファイルには、複数のビュー、グローバルフィルター、数式、プロパティ設定、カスタム集計を含めることができます。

ファイル形式

Base ファイルは .base 拡張子を使用し、有効な YAML を含みます。また、Markdown のコードブロックに埋め込むこともできます。

完全なスキーマ

# Global filters apply to ALL views in the base
filters:
  # Can be a single filter string
  # OR a recursive filter object with and/or/not
  and: []
  or: []
  not: []

# Define formula properties that can be used across all views
formulas:
  formula_name: 'expression'

# Configure display names and settings for properties
properties:
  property_name:
    displayName: "Display Name"
  formula.formula_name:
    displayName: "Formula Display Name"
  file.ext:
    displayName: "Extension"

# Define custom summary formulas
summaries:
  custom_summary_name: 'values.mean().round(3)'

# Define one or more views
views:
  - type: table | cards | list | map
    name: "View Name"
    limit: 10                    # Optional: limit results
    groupBy:                     # Optional: group results
      property: property_name
      direction: ASC | DESC
    filters:                     # View-specific filters
      and: []
    order:                       # Properties to display in order
      - file.name
      - property_name
      - formula.formula_name
    summaries:                   # Map properties to summary formulas
      property_name: Average

フィルター構文

フィルターを使って結果を絞り込みます。グローバルまたはビューごとに適用できます。

フィルター構造
# Single filter
filters: 'status == "done"'

# AND - all conditions must be true
filters:
  and:
    - 'status == "done"'
    - 'priority > 3'

# OR - any condition can be true
filters:
  or:
    - 'file.hasTag("book")'
    - 'file.hasTag("article")'

# NOT - exclude matching items
filters:
  not:
    - 'file.hasTag("archived")'

# Nested filters
filters:
  or:
    - file.hasTag("tag")
    - and:
        - file.hasTag("book")
        - file.hasLink("Textbook")
    - not:
        - file.hasTag("book")
        - file.inFolder("Required Reading")
フィルター演算子
演算子説明
==等しい
!=等しくない
>より大きい
<より小さい
>=以上
<=以下
&&論理積
||論理和
!論理否定

プロパティ

プロパティの3つの種類
  1. ノートプロパティ - フロントマターから取得します:note.author または単に author
  2. ファイルプロパティ - ファイルのメタデータです:file.name、file.mtime など
  3. 数式プロパティ - 計算値です:formula.my_formula
ファイルプロパティのリファレンス
プロパティ型説明
file.nameStringファイル名
file.basenameString拡張子を除いたファイル名
file.pathStringファイルへのフルパス
file.folderString親フォルダーのパス
file.extStringファイル拡張子
file.sizeNumberファイルサイズ(バイト)
file.ctimeDate作成日時
file.mtimeDate更新日時
file.tagsListファイル内のすべてのタグ
file.linksListファイル内の内部リンク
file.backlinksListこのファイルにリンクしているファイル
file.embedsListノート内の埋め込み
file.propertiesObjectすべてのフロントマタープロパティ
this キーワード
  • メインコンテンツ領域では、Base ファイル自体を指します
  • 埋め込まれている場合は、埋め込み元のファイルを指します
  • サイドバーでは、メインコンテンツ内のアクティブなファイルを指します

数式の構文

数式はプロパティから値を計算します。formulas セクションで定義します。

formulas:
  # Simple arithmetic
  total: "price * quantity"

  # Conditional logic
  status_icon: 'if(done, "✅", "⏳")'

  # String formatting
  formatted_price: 'if(price, price.toFixed(2) + " dollars")'

  # Date formatting
  created: 'file.ctime.format("YYYY-MM-DD")'

  # Calculate days since created (use .days for Duration)
  days_old: '(now() - file.ctime).days'

  # Calculate days until due date
  days_until_due: 'if(due_date, (date(due_date) - today()).days, "")'

関数のリファレンス

グローバル関数
関数シグネチャ説明
date()date(string): date文字列を日付に変換します。形式:YYYY-MM-DD HH:mm:ss
duration()duration(string): duration期間の文字列を解析します
now()now(): date現在の日時
today()today(): date今日の日付(時刻は 00:00:00)
if()if(condition, trueResult, falseResult?)条件分岐
min()min(n1, n2, ...): number最小の数値
max()max(n1, n2, ...): number最大の数値
number()number(any): number数値に変換します
link()link(path, display?): Linkリンクを作成します
list()list(element): Listまだリストでない場合、リストに変換します
file()file(path): fileファイルオブジェクトを取得します
image()image(path): imageレンダリング用の画像を作成します
icon()icon(name): icon名前で Lucide アイコンを指定します
html()html(string): htmlHTML としてレンダリングします
escapeHTML()escapeHTML(string): stringHTML 文字をエスケープします
任意の型に使える関数
関数シグネチャ説明
isTruthy()any.isTruthy(): booleanブール値に変換します
isType()any.isType(type): boolean型を確認します
toString()any.toString(): string文字列に変換します
日付関数とフィールド

フィールド: date.year、date.month、date.day、date.hour、date.minute、date.second、date.millisecond

関数シグネチャ説明
date()date.date(): date時刻部分を削除
format()date.format(string): stringMoment.js のパターンでフォーマット
time()date.time(): string時刻を文字列として取得
relative()date.relative(): string相対時間を人間が読みやすい形式で取得
isEmpty()date.isEmpty(): boolean日付の場合は常に false
Duration 型

2 つの日付を減算すると、結果は数値ではなく Duration 型になります。Duration には固有のプロパティとメソッドがあります。

Duration フィールド:

フィールド型説明
duration.daysNumberDuration の合計日数
duration.hoursNumberDuration の合計時間数
duration.minutesNumberDuration の合計分数
duration.secondsNumberDuration の合計秒数
duration.millisecondsNumberDuration の合計ミリ秒数

重要: Duration は .round()、.floor()、.ceil() を直接サポートしていません。まず .days のような数値フィールドにアクセスしてから、数値関数を適用する必要があります。

# CORRECT: Calculate days between dates
"(date(due_date) - today()).days"                    # Returns number of days
"(now() - file.ctime).days"                          # Days since created

# CORRECT: Round the numeric result if needed
"(date(due_date) - today()).days.round(0)"           # Rounded days
"(now() - file.ctime).hours.round(0)"                # Rounded hours

# WRONG - will cause error:
# "((date(due) - today()) / 86400000).round(0)"      # Duration doesn't support division then round
日付の算術演算
# Duration units: y/year/years, M/month/months, d/day/days,
#                 w/week/weeks, h/hour/hours, m/minute/minutes, s/second/seconds

# Add/subtract durations
"date + \"1M\""           # Add 1 month
"date - \"2h\""           # Subtract 2 hours
"now() + \"1 day\""       # Tomorrow
"today() + \"7d\""        # A week from today

# Subtract dates returns Duration type
"now() - file.ctime"                    # Returns Duration
"(now() - file.ctime).days"             # Get days as number
"(now() - file.ctime).hours"            # Get hours as number

# Complex duration arithmetic
"now() + (duration('1d') * 2)"
文字列関数

フィールド: string.length

関数シグネチャ説明
contains()string.contains(value): boolean部分文字列が含まれているか確認
containsAll()string.containsAll(...values): booleanすべての部分文字列が含まれているか確認
containsAny()string.containsAny(...values): booleanいずれかの部分文字列が含まれているか確認
startsWith()string.startsWith(query): booleanクエリで始まるか確認
endsWith()string.endsWith(query): booleanクエリで終わるか確認
isEmpty()string.isEmpty(): boolean空か、存在しないか確認
lower()string.lower(): string小文字に変換
title()string.title(): stringタイトルケースに変換
trim()string.trim(): string空白を削除
replace()string.replace(pattern, replacement): stringパターンを置換
repeat()string.repeat(count): string文字列を繰り返す
reverse()string.reverse(): string文字列を反転
slice()string.slice(start, end?): string部分文字列を取得
split()string.split(separator, n?): listリストに分割
数値関数
関数シグネチャ説明
abs()number.abs(): number絶対値
ceil()number.ceil(): number切り上げ
floor()number.floor(): number切り捨て
round()number.round(digits?): number指定桁数に丸める
toFixed()number.toFixed(precision): string固定小数点表記
isEmpty()number.isEmpty(): boolean存在しないか確認
リスト関数

フィールド: list.length

関数シグネチャ説明
contains()list.contains(value): boolean要素が存在するか確認
containsAll()list.containsAll(...values): booleanすべての要素が存在するか確認
containsAny()list.containsAny(...values): booleanいずれかの要素が存在するか確認
filter()list.filter(expression): list条件でフィルタリング(value、index を使用)
map()list.map(expression): list要素を変換(value、index を使用)
reduce()list.reduce(expression, initial): any単一の値に集約(value、index、acc を使用)
flat()list.flat(): listネストされたリストを平坦化
join()list.join(separator): string文字列に結合
reverse()list.reverse(): list順序を反転
slice()list.slice(start, end?): listサブリストを取得
sort()list.sort(): list昇順でソート
unique()list.unique(): list重複を削除
isEmpty()list.isEmpty(): boolean要素がないか確認
ファイル関数
関数シグネチャ説明
asLink()file.asLink(display?): Linkリンクに変換します
hasLink()file.hasLink(otherFile): booleanファイルへのリンクがあるかどうかを返します
hasTag()file.hasTag(...tags): booleanいずれかのタグがあるかどうかを返します
hasProperty()file.hasProperty(name): booleanプロパティがあるかどうかを返します
inFolder()file.inFolder(folder): booleanフォルダーまたはサブフォルダー内にあるかどうかを返します
リンク関数
関数シグネチャ説明
asFile()link.asFile(): fileファイルオブジェクトを取得します
linksTo()link.linksTo(file): booleanファイルへのリンクかどうかを返します
オブジェクト関数
関数シグネチャ説明
isEmpty()object.isEmpty(): booleanプロパティがないかどうかを返します
keys()object.keys(): listキーのリストを返します
values()object.values(): list値のリストを返します
正規表現関数
関数シグネチャ説明
matches()regexp.matches(string): boolean一致するかどうかをテストします

ビューの種類

テーブルビュー
views:
  - type: table
    name: "My Table"
    order:
      - file.name
      - status
      - due_date
    summaries:
      price: Sum
      count: Average
カードビュー
views:
  - type: cards
    name: "Gallery"
    order:
      - file.name
      - cover_image
      - description
リストビュー
views:
  - type: list
    name: "Simple List"
    order:
      - file.name
      - status
マップビュー

緯度/経度のプロパティとMapsコミュニティプラグインが必要です。

views:
  - type: map
    name: "Locations"
    # Map-specific settings for lat/lng properties

デフォルトの集計数式

名前入力タイプ説明
Average数値算術平均
Min数値最小値
Max数値最大値
Sum数値すべての数値の合計
Range数値最大値 - 最小値
Median数値数学的な中央値
Stddev数値標準偏差
Earliest日付最も早い日付
Latest日付最も遅い日付
Range日付最新の日付 - 最も早い日付
Checkedブール値true の値の数
Uncheckedブール値false の値の数
Empty任意空の値の数
Filled任意空でない値の数
Unique任意一意な値の数

完全な例

タスクトラッカーのベース
filters:
  and:
    - file.hasTag("task")
    - 'file.ext == "md"'

formulas:
  days_until_due: 'if(due, (date(due) - today()).days, "")'
  is_overdue: 'if(due, date(due) < today() && status != "done", false)'
  priority_label: 'if(priority == 1, "🔴 High", if(priority == 2, "🟡 Medium", "🟢 Low"))'

properties:
  status:
    displayName: Status
  formula.days_until_due:
    displayName: "Days Until Due"
  formula.priority_label:
    displayName: Priority

views:
  - type: table
    name: "Active Tasks"
    filters:
      and:
        - 'status != "done"'
    order:
      - file.name
      - status
      - formula.priority_label
      - due
      - formula.days_until_due
    groupBy:
      property: status
      direction: ASC
    summaries:
      formula.days_until_due: Average

  - type: table
    name: "Completed"
    filters:
      and:
        - 'status == "done"'
    order:
      - file.name
      - completed_date
読書リストのベース
filters:
  or:
    - file.hasTag("book")
    - file.hasTag("article")

formulas:
  reading_time: 'if(pages, (pages * 2).toString() + " min", "")'
  status_icon: 'if(status == "reading", "📖", if(status == "done", "✅", "📚"))'
  year_read: 'if(finished_date, date(finished_date).year, "")'

properties:
  author:
    displayName: Author
  formula.status_icon:
    displayName: ""
  formula.reading_time:
    displayName: "Est. Time"

views:
  - type: cards
    name: "Library"
    order:
      - cover
      - file.name
      - author
      - formula.status_icon
    filters:
      not:
        - 'status == "dropped"'

  - type: table
    name: "Reading List"
    filters:
      and:
        - 'status == "to-read"'
    order:
      - file.name
      - author
      - pages
      - formula.reading_time
プロジェクトノートのベース
filters:
  and:
    - file.inFolder("Projects")
    - 'file.ext == "md"'

formulas:
  last_updated: 'file.mtime.relative()'
  link_count: 'file.links.length'

summaries:
  avgLinks: 'values.filter(value.isType("number")).mean().round(1)'

properties:
  formula.last_updated:
    displayName: "Updated"
  formula.link_count:
    displayName: "Links"

views:
  - type: table
    name: "All Projects"
    order:
      - file.name
      - status
      - formula.last_updated
      - formula.link_count
    summaries:
      formula.link_count: avgLinks
    groupBy:
      property: status
      direction: ASC

  - type: list
    name: "Quick List"
    order:
      - file.name
      - status
デイリーノートのインデックス
filters:
  and:
    - file.inFolder("Daily Notes")
    - '/^\d{4}-\d{2}-\d{2}$/.matches(file.basename)'

formulas:
  word_estimate: '(file.size / 5).round(0)'
  day_of_week: 'date(file.basename).format("dddd")'

properties:
  formula.day_of_week:
    displayName: "Day"
  formula.word_estimate:
    displayName: "~Words"

views:
  - type: table
    name: "Recent Notes"
    limit: 30
    order:
      - file.name
      - formula.day_of_week
      - formula.word_estimate
      - file.mtime

ベースの埋め込み

Markdownファイルに埋め込みます。

![[MyBase.base]]


![[MyBase.base#View Name]]

YAMLの引用符のルール

  • ダブルクォートを含む数式にはシングルクォートを使用します:'if(done, "Yes", "No")'
  • 単純な文字列にはダブルクォートを使用します:"My View Name"
  • 複雑な式では、入れ子になった引用符を適切にエスケープします

よく使われるパターン

タグでフィルター
filters:
  and:
    - file.hasTag("project")
フォルダーでフィルター
filters:
  and:
    - file.inFolder("Notes")
日付範囲でフィルター
filters:
  and:
    - 'file.mtime > now() - "7d"'
プロパティ値でフィルター
filters:
  and:
    - 'status == "active"'
    - 'priority >= 3'
複数の条件を組み合わせる
filters:
  or:
    - and:
        - file.hasTag("important")
        - 'status != "done"'
    - and:
        - 'priority == 1'
        - 'due != ""'

参考資料

コメント