# Obsidian Base Query

> 通过 `obsidian` CLI 运行已有的 Obsidian Bases（`.base` 文件）取回结果，并解读、调试 base。当前工作目录本身就是一个 Obsidian vault。当用户要「跑某个 base 看结果」「把某视图的笔记列出来」「这个 base 为什么没出现某篇笔记」「这个 base 在筛什么」这类针对已建好视图的结构化检索或排错需求时走本 skill。触发示例：「跑一下进行中任务这个 base」「按 json 给我阅读清单库的结果」「日记索引为什么少了昨天那篇」。

- **Type:** Skill
- **Install:** `agentstack add skill-21noises-agent-skills-obsidian-base-query`
- **Verified:** Yes — security-reviewed for prompt injection and unsafe behavior
- **Seller:** [21noises](https://agentstack.voostack.com/s/21noises)
- **Installs:** 0
- **Category:** [Productivity](https://agentstack.voostack.com/c/productivity)
- **Latest version:** 0.1.0
- **License:** MIT
- **Upstream author:** [21noises](https://github.com/21noises)
- **Source:** https://github.com/21noises/agent-skills/tree/main/plugins/obsidian/skills/obsidian-base-query

## Install

```sh
agentstack add skill-21noises-agent-skills-obsidian-base-query
```

Requires the [AgentStack CLI](https://agentstack.voostack.com/docs/cli). Works with Claude Code, Cursor, and any MCP-compatible agent.

## About

你在这里做两件事：运行已有的 `.base` 取回结果，以及在结果不符预期时解读、调试。你只读，不新建也不修改任何笔记与 `.base`，这些写入都归 `obsidian-base-author`。

问题能不能用 base 回答、该不该为它新建 base，不由你负责判断。

如果既有 bases 没有能与问题相匹配的，你唯一出口是立即调用 Skill 工具、skill 名 `obsidian-base-author`，把用户的原始需求原样转交。不要自己回答，不要改用全文搜索或手工读笔记凑答案，也不要只报告「没有这个 base」就收尾。

## 前置条件

Obsidian 1.12.7 及以上，并已启用 CLI：*Settings → General → Command line interface*（一次性注册后会生成 `obsidian` 命令）。若命令报「command not found」，说明 CLI 尚未注册，请如实报告，不要改用其他工具绕开。

命令依赖 Obsidian 应用运行，但不必手动先开；首条命令会自动把它启动起来，可能略有延迟。

## 关键约定

1. 一个 `.base` 文件只放一个视图。
2. 文件名主体等于视图的 `name` 字段，看文件名就能认出是什么视图。

## 工作流

1. **先列出已有 base。** 跑 `obsidian bases` 列出 vault 里全部 `.base` 文件。这一步强制，用来在已有文件里定位目标，而不是凭空猜文件名。
2. **定位目标。** 在第 1 步的清单里按文件名挑出目标；文件名不足以判断时，用 Read 打开那个 `.base` 看它筛什么。若整个清单里都没有对得上的 base，那不是名字一时对不上，而是它还不存在，按上文立即调用 Skill 工具转交 `obsidian-base-author`，本步到此结束，不要在没有 base 的前提下继续往下跑查询，也不要自己另寻答案。
3. **跑查询取结果。** `obsidian base:query path= format=`。`path` 取第 1 步列出的完整路径，要带扩展名，值含空格时加引号；单视图无歧义，`view=` 可省。格式按消费方选：给人看用 `md`，给程序用 `json`、`csv`、`tsv`，只要命中文件清单用 `paths`，默认 `md`。
4. **整理回报。** 把结果按用户需要的形式呈现。

## 解读与调试分支

结果不符预期时：

1. 用 Read 读那个 `.base` 文件。
2. 逐条展开 `filters` 的 `and`、`or`、`not`，解析属性的类型前缀以及 `this` 的语境含义；类型前缀有 `note.`、`file.`、`formula.`，无前缀时默认按 note。
3. 对照常见原因排查：属性名或类型不匹配，公式输出类型由底层数据与函数返回值决定；缺空值保护导致该行报错；`file.hasTag` 连带命中嵌套标签、精确字符串比较不会；`file.inFolder` 连带命中子文件夹；链接相等与 `this` 语境；日期相减得毫秒数，误用不存在的 `.days` 字段会算空，求天数要除以 `86400000`；`file.backlinks`、`file.properties` 不随 vault 变化自动刷新。
4. 需要更深的筛选语法、类型行为或函数语义来判断，或定位后要改筛选，都立即调用 Skill 工具转交 `obsidian-base-author`，不要凭印象自行改写筛选或猜测语义。

## Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

- **Author:** [21noises](https://github.com/21noises)
- **Source:** [21noises/agent-skills](https://github.com/21noises/agent-skills)
- **License:** MIT

Install and usage instructions live in the source repository linked above.

## Pricing

- **Free** — Free

## Security capabilities

Automated source analysis of v0.1.0 — what this tool can access:

- **Network access:** no
- **Filesystem access:** no
- **Shell / process execution:** no
- **Environment & secrets:** no
- **Dynamic code execution:** no

*"Yes" means the capability is present in the source — more access means more to trust, not that it is unsafe.*


## Versions

- **0.1.0** — security scan: passed — Imported from the upstream source.

## Links

- Listing page: https://agentstack.voostack.com/l/skill-21noises-agent-skills-obsidian-base-query
- Seller: https://agentstack.voostack.com/s/21noises
- Browse the marketplace: https://agentstack.voostack.com/browse

---
Listed on AgentStack — the marketplace for AI agent skills and MCP servers. Every listing is security-reviewed. Creators keep 70%.
