search

Command "search" from treylom/knowledge-manager, covering /km:search — vault 통합 검색, phase -1: 설정 읽기, phase 0: 모드 결정, 플래그 파싱 and auto 라우팅.

Command for Claude Code

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add commands/treylom/knowledge-manager/search
Clone the repo
git clone --depth 1 https://github.com/treylom/knowledge-manager

Made for: Claude Code.

Per session 51 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 7,851 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 1 finding. Scan, not verified.
Origin unknown No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00051 $0.07851
Opus 5 $0.00026 $0.03925
Sonnet 5 $0.00010 $0.01570
Haiku 4.5 $0.00005 $0.00785

Measured today against content hash d0d4e74c4b01, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

search scanned grade A with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured today.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Makes network callslowCapability

Not a fault in itself. Listed so you know the mod talks to something, and to what.

> 🚨 **실행 순서 계약 (고정 — 첫 행동을 여기서 정한다)**: ① Phase -1 로 설정 2개(`VAULT_PATH`·`SEARCH_ENDPOINT`)를 읽는다 → ② **곧바로 Tier 1 서버 검색 curl 을 실행한다.** 이 ①② 보다 먼저 vault 파일을 검색·나열·읽기(rg / grep / find / ls / Read) ❌ — 검색의 1차 수단은 서버이고, 로컬 파일
.claude/commands/search.md · 281 lines

How it starts

The opening of the file, as written. The whole thing — 281 lines — stays where its author put it; the contents beside it link to each section on GitHub.

/km:search — vault 통합 검색

$ARGUMENTS

핵심 설계: 검색 창구는 이 명령 하나입니다. 뒤에서 어떤 검색 엔진이 도는지는 자동으로 결정됩니다 — ① GraphRAG 서버(설치돼 있으면) → ② Obsidian CLI → ③ Obsidian MCP → ④ 텍스트 검색 순서로, 앞 단계가 없거나 실패하면 자동으로 다음 단계로 넘어갑니다. GraphRAG를 아직 설치하지 않았어도 이 명령은 그대로 동작합니다(②~④가 받아줍니다). 나중에 GraphRAG 스택을 얹으면 같은 명령이 자동으로 ①을 쓰기 시작합니다.

찾는 범위: 이 명령은 vault 안의 문서·개념·문서 사이 관계를 찾습니다. 반면 과거 대화에서 무슨 말이 오갔는지·어떤 결정이 왜 내려졌는지는 성격이 다른 질문이라, 대화 기록을 따로 보관·검색하는 도구가 있다면 그쪽이 먼저입니다. 둘 다 봐야 하는 질문이라면 지금 기준·현재 상태는 문서 쪽, 원래 발언·결정 경위는 대화 기록 쪽을 우선하세요. 두 결과가 어긋나면 감추지 말고 현재 기준과거 경위로 나눠 적는 편이 낫습니다. 그리고 한쪽에서 안 나왔다고 다른 쪽에도 없다고 단정하지 마세요 — 서로 다른 코퍼스입니다.

🚨 실행 순서 계약 (고정 — 첫 행동을 여기서 정한다): ① Phase -1 로 설정 2개(VAULT_PATH·SEARCH_ENDPOINT)를 읽는다 → ② 곧바로 Tier 1 서버 검색 curl 을 실행한다. 이 ①② 보다 먼저 vault 파일을 검색·나열·읽기(rg / grep / find / ls / Read) ❌ — 검색의 1차 수단은 서버이고, 로컬 파일은 Tier 1 의 원문 확보 계약(VAULT_MODE=same)이 허용할 때 또는 Tier 1 이 실패로 판정된 뒤(Tier 2~4)에만 연다. "vault 를 확인해보겠다"며 로컬부터 뒤지는 첫 행동 = 이 계약 위반이다.

Phase -1: 설정 읽기

  1. km-config.json을 찾는다 (현재 폴더 → 플러그인 설치 시 setup이 만든 위치 순).
  2. storage.obsidian.vaultPathVAULT_PATH. 없으면 사용자에게 vault 경로를 1회 묻고 진행.
    • 추측 금지: 설정이 없을 때 그럴듯한 경로를 스스로 골라 검색하면 낡은 사본에서 답하고도 출처가 붙어 있어 사용자가 오류를 알아챌 수 없다(실측 사례: 백업 사본 17,923개 md 를 라이브 vault 로 착각). 반드시 묻는다.
    • "진짜 쓰는 vault" 판정은 추측·후보 순회가 아니라 Obsidian 자기 설정으로 한다 (⚠️ km-config 에 vaultPath 가 이미 있으면 아래 판정을 실행하지 않는다 — 그 값이 정답) — obsidian.json 에서 "open": true 인 항목이 사용자가 실제로 열어 두는 vault 다. 백업 사본·형제 폴더도 .obsidian 을 갖고 있어서 그것만으론 안 갈린다.
      # 경로를 직접 짚는다 — 넓은 find 로 훑지 말 것(/mnt/c/Users 전수 탐색은 느리고 빈손으로 끝난다).
      OBSIDIAN_JSON=$(ls -1 \
        "$HOME/Library/Application Support/obsidian/obsidian.json" \
        /mnt/c/Users/*/AppData/Roaming/obsidian/obsidian.json \
        "$APPDATA/obsidian/obsidian.json" 2>/dev/null | head -1)
      python3 -c 'import json,sys;d=json.load(open(sys.argv[1]))["vaults"];print("\n".join(v["path"] for v in d.values() if v.get("open")))' "$OBSIDIAN_JSON"
      
      WSL 에서는 이 값이 윈도우 경로(C:\Users\...)로 나온다 — wslpath -u 로 바꿔 쓴다. 이 파일이나 "open": true 항목을 못 찾았을 때만 사용자에게 묻는다.
    • 사용자가 준 경로도 한 번 검증한다 — .obsidian 폴더 존재, 최근 수정된 md 유무. 둘 다 아니면 그 경로를 쓰기 전에 다시 확인한다.
  3. obsidianCli.pathOBSIDIAN_CLI (비어 있으면 아래 Tier 2의 자동 감지 사용).
  4. SEARCH_ENDPOINT = linking.semantic_adapter.endpoint → 환경변수 GRAPHRAG_API_URL → 기본값 http://127.0.0.1:8400 순. 미설정이어도 기본값을 탐침한다 — 로컬에 서버가 없으면 즉시 연결 거부로 끝나 지연이 거의 없고(--connect-timeout 3은 상한일 뿐), 덕분에 나중에 /tofugraph build로 스택을 얹으면 설정 변경 없이 같은 명령이 자동으로 Tier 1을 쓰기 시작한다.

Read the full file on GitHub · 281 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. today First seen · 281 lines · 51 tokens per session scan A d0d4e74c4b01

Subscribe to this mod's changes

search is a command published in the GitHub repository treylom/knowledge-manager (227 stars, last pushed today), licensed MIT. It adds 51 tokens to every session and 7,851 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it A with 1 finding (makes network calls). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-01.