Building a Local Q&A Knowledge Base with Obsidian and Claude Code

    This article explains how to set up a private, local-first knowledge base where you can ask natural language questions. It combines Obsidian for note management, Claude Code as the command-line AI assistant, and DeepSeek as the underlying LLM. The guide covers the three-layer architecture, step-by-step installation, secure API key handling, protocol compatibility checks, troubleshooting, permission controls, cost estimation, and backup strategies. It also includes a pre-launch checklist for safe and effective deployment.

    1. Overall Architecture

    The knowledge base consists of three layers:

    • Data layer: Obsidian manages your notes. Notes are stored as plain Markdown files in a local folder (called a vault) — no cloud storage is required.
    • Orchestration layer: Claude Code, a terminal-based AI coding assistant, reads the vault folder, searches files, and executes commands. No Obsidian plugin is needed for integration.
    • Model layer: DeepSeek provides the LLM that processes questions and generates answers.

    Obsidian requires no bridge plugin. Claude Code accesses the vault folder directly. You edit notes in Obsidian and ask questions in the terminal; both tools operate on the same set of files.

    The key thing to verify is the model layer connection. Claude Code sends requests using the Anthropic Messages protocol, which may differ from the protocol supported by DeepSeek’s API. This affects the configuration approach described in Section 5.

    This architecture keeps layers independent. Changing the model provider only requires updating Claude Code’s connection settings — your notes never need to be migrated.

    2. Setting Up the Vault

    Step 1: Install Obsidian and create a vault. Download the installer for your operating system from the Obsidian website. On first launch, choose “Create new vault” to create a local vault folder. Use an English path with no spaces, e.g., D:\notes\knowledge-base. Chinese characters or spaces in paths can cause parsing issues in command-line tools.

    Step 2: Enable disk encryption. Notes are stored as plaintext locally. If the device is lost or accessed by others, file contents are exposed. Windows users can enable BitLocker; macOS users can enable FileVault. This protects data at rest.

    Step 3: Track versions with Git. Run git init in the vault directory and commit after each editing session. If you accidentally delete or modify content, use git log to find historical versions and restore them.

    3. Community Plugins and Security Settings

    By default, Obsidian runs in “Restricted Mode,” which allows only core plugins. Disabling Restricted Mode enables third-party plugins, which can execute code — increasing risk.

    Only disable Restricted Mode when you truly need a specific plugin. Follow these rules:

    1. Install plugins only from the plugin marketplace or trusted code repositories.
    2. After installation, review the permissions the plugin requests — don’t enable features you don’t need.
    3. Pin plugin versions; test upgrades in a separate vault before applying them to your main vault.
    4. Keep the vault that contains sensitive data in Restricted Mode and install no third-party plugins.

    Consider creating two vaults to isolate risk. Use plugins in your everyday notes vault, but keep a sensitive-data vault in Restricted Mode and never connect it to AI tools.

    4. Installing Claude Code

    Step 1: Install Node.js. Claude Code depends on Node.js. Check the current minimum version requirement on the Node.js website or Claude Code official documentation. After installation, verify in the terminal:

    1. node -v

    If a version number appears, the installation succeeded. Windows users must ensure “Add to PATH” is checked during Node.js installation.

    Step 2: Install Claude Code. Run the following command in the terminal:

    1. npm install -g @anthropic-ai/claude-code

    Verify with claude --version. If the installation times out, you may temporarily switch to a trusted npm mirror. After installation, restore the original npm registry to avoid dependency confusion.

    Step 3: Enter the vault directory and start.

    1. cd D:\notes\knowledge-base
    2. claude

    Claude Code operates within that directory. You can ask natural language questions, e.g., “Find all meeting notes about Project A in 2026 and summarize action items.”

    5. Connecting DeepSeek

    This step is the most error-prone. Claude Code uses the Anthropic Messages protocol. DeepSeek’s API protocol is defined in its official documentation. Before configuring, confirm two things:

    1. Does the official documentation list an endpoint compatible with Claude Code? If yes, simply fill in the base URL, authentication method, and model name.
    2. If only an OpenAI-compatible endpoint is provided, you must run a protocol-conversion proxy locally or on your intranet. The proxy receives Claude Code requests and forwards them to DeepSeek’s API. In that case, ANTHROPIC_BASE_URL points to the proxy address, and the auth token is one you define for the proxy.

    In either case, never enter your DeepSeek secret key into the Anthropic official URL — it will not work and would send the key to the wrong server.

    Step 1: Create an API key. Log in to the DeepSeek platform, go to the API key management page, and create a new key. The key is shown only once at creation time; save it securely immediately. Lost keys must be regenerated.

    Step 2: Protect the key. Never place the key in the vault or commit it to a Git repository. Store it in Claude Code’s configuration file in your user directory, and restrict access permissions.

    • macOS / Linux: ~/.claude/settings.json
    • Windows: %USERPROFILE%\.claude\settings.json

    Example configuration (replace the angle-bracket content with values from the official docs or your proxy):

    1. {
    2. "env": {
    3. "ANTHROPIC_BASE_URL": "<endpoint from official docs, or local proxy address>",
    4. "ANTHROPIC_AUTH_TOKEN": "<access token required by that endpoint>",
    5. "ANTHROPIC_MODEL": "<model identifier confirmed in the console>"
    6. }
    7. }

    Claude Code’s auth variable names may change between versions; common names are ANTHROPIC_AUTH_TOKEN and ANTHROPIC_API_KEY. Check the current documentation before writing.

    Step 3: Confirm the model name. Model names are subject to change. Check the DeepSeek console or official documentation for the current list of available model identifiers, e.g., deepseek-chat. Do not use unknown identifiers — requests will fail.

    6. Verification and Troubleshooting

    Start claude and send a simple “Hello.” If you get a normal reply, the pipeline is working. If not, check the following table:

    Symptom Possible Cause Resolution
    401 Wrong or expired key Regenerate the key; verify the auth variable name
    404 Incorrect endpoint path Fix the URL in docs or proxy configuration
    400 or 422 Model name invalid or wrong parameters Confirm the model identifier in the console
    402 or insufficient balance Account balance low Add credits or check billing
    429 Request rate too high Retry later or reduce concurrency
    5xx Server-side exception Retry later; check platform status

    Debug in this order: first check the platform status page and billing, then verify the key permissions and auth variable name, and finally inspect the endpoint and model name. Do not repeatedly retry with a wrong configuration — it only wastes requests.

    Note that HTTP 200 only indicates network connectivity and authentication success. It does not prove the model name or other parameters are correct. Only a normal response guarantees the model is usable.

    7. Directory Permissions

    The safest approach is to remove sensitive files from the vault. Passwords, ID scans, and banking information should live in a separate directory not connected to AI tools.

    If sensitive files must remain in the vault, you can add deny rules in settings.json. The following syntax applies to current common versions; verify against the official documentation for your installed version.

    1. {
    2. "permissions": {
    3. "deny": [
    4. "Read(./secrets/**)",
    5. "Read(./.env)"
    6. ]
    7. }
    8. }

    Test after configuring. Ask Claude Code to read a denied file and confirm it returns a denial, not file content. Only after passing this test can you consider the rule effective. Never skip this step — a miswritten rule will not be reported.

    8. Dual-Model Strategy

    Complex tasks and simple tasks require different models. Long-document summarization and cross-file reasoning need stronger models. Tagging or title generation can be handled by cheaper models.

    Task Type Suggested Model Reasoning
    Cross-file retrieval, long summaries Stronger main model Requires better reasoning and context understanding
    Tag classification, title generation Cheaper lightweight model Simple tasks, cost-sensitive
    Sensitive content processing Do not send to any external API Data should not leave the local machine

    Claude Code’s support for multi-model switching may vary by version. For automated classification tasks, you can directly call the lightweight model’s API from a script, instead of relying on interactive mode.

    9. Data Security and Backup

    Since notes are stored locally, backups are your responsibility. Follow the 3-2-1 strategy: keep 3 copies, on 2 different types of storage media, with 1 copy offsite. For example, one copy on your computer’s hard drive, one on an external drive, and one on an encrypted cloud drive or another device.

    When using cloud APIs, question content is sent to the model provider for processing. Check the following list before sending:

    • Phone numbers, ID numbers, bank card numbers: replace with placeholders like [phone].
    • Client names, contract numbers: use aliases unless needed for analysis.
    • Internal system URLs, passwords, tokens: remove completely; do not appear in note text.
    • For large amounts of data, batch sanitize first, then feed to the AI.

    Refer to DeepSeek’s official privacy policy for specific data usage terms.

    10. Cost Estimation

    API costs are per token, split into input and output. Monthly cost estimate:

    Monthly cost = Daily calls × 30 × (Input tokens per call × Input price + Output tokens per call × Output price)

    Example: 100 calls per day, 3000 input tokens and 800 output tokens per call. Assume input price is ¥1 per million tokens, output price is ¥2 per million tokens. Daily cost:

    100 × (3000 × 1 + 800 × 2) ÷ 1,000,000 = ¥0.46

    Monthly cost ≈ ¥13.8. These prices are examples only. Check DeepSeek’s official pricing page for current rates, and rely on the platform’s token statistics.

    Some platforms offer cache discounts on repeated context prefixes. This caching applies to input prefixes only, not to generated answers. The discount only applies when the input prefix is repeated; whether it hits depends on the platform’s rules.

    11. Team Collaboration and Automation

    For multiple users, place the vault in a Git repository with access control. Each member clones and pushes locally. Repository permissions should be role-based to avoid everyone reading all content.

    Exclude sensitive directories via .gitignore; never push them to a shared repository. Add these lines to the repository root’s .gitignore:

    1. secrets/
    2. .env

    Claude Code supports non-interactive mode with claude -p for single-shot tasks. Combined with system schedulers (cron on Linux, Task Scheduler on Windows), you can automatically have the AI summarize new notes daily and save results to a specific file. Sending email requires extra scripting; be mindful of content sensitivity.

    Cross-language retrieval is possible: ask in Chinese, have the model read English materials, and answer in Chinese. Response quality depends on the specific model and content. Before production use, test with several known-answer questions.

    Pre-Launch Checklist

    Confirm the following before using the system:

    • Interface protocol confirmed with official docs or proxy; configuration address and auth variable names match.
    • API key only stored in the user-level config file; no keys exist in the vault or Git repository.
    • Sensitive files moved out of the vault, or deny rules configured and tested with a read attempt.
    • Backups completed per the 3-2-1 strategy, and at least one restore drill performed.
    • Monthly cost reviewed with example rates and actual billing; balance alerts set.