AI Context Sync
unlistedby Mitchell Tatge
Sync your AI context notes to CLAUDE.md, .cursor/rules/, AGENTS.md, and more. One source of truth for all your AI coding assistants.
AI Context Sync for Obsidian
Sync one Obsidian note into marked sections in your coding assistants' project instructions, while preserving the text around those sections.
Experimental desktop plugin · MIT · 1.1.0
This is a small local export tool. It does not call an AI service, share your vault, or refresh an assistant's existing conversation. You choose the note, project directories, and destinations. Start a fresh assistant session when its instruction loader requires it.
Supported output formats
| Target | File | Behavior |
|---|---|---|
| Claude Code | CLAUDE.md | Append or update one managed section |
| Codex / AGENTS.md | AGENTS.md | Append or update one managed section |
| GitHub Copilot | .github/copilot-instructions.md | Append or update one managed section |
| Cursor Agent | .cursor/rules/ai-context-sync.mdc | Create a dedicated always-on rule; refuse an existing unowned rule |
These filenames follow the documented Claude Code, Codex, Copilot, and Cursor file contracts. Automated tests check the output and sync behavior; fresh native assistant sessions have not been tested with this release. File creation alone does not prove a client loaded the context. Other assistants and Obsidian mobile are outside this release's scope.
Install
This plugin is not published in Obsidian Community Plugins. Use a local build or an attached GitHub release asset. No installer changes your vault automatically.
Build from source
Requires desktop Obsidian, Node.js 20 or later, npm, and Git. Python 3 is needed only for optional release packaging.
git clone https://github.com/mctatge/obsidian-ai-context-sync.git
cd obsidian-ai-context-sync
npm ci
npm run check
- Create
<your-vault>/.obsidian/plugins/ai-context-sync/. - Copy
main.js,manifest.json, andstyles.cssfrom the checkout into that directory. Keep your own vault path private. - Reload Obsidian. In Settings → Community plugins, enable AI Context Sync. Follow Obsidian's prompt if third-party plugins are disabled.
From a GitHub release
For a release with attached runtime assets, download ai-context-sync-1.1.0.zip and extract its ai-context-sync folder into your vault's .obsidian/plugins/ directory. Alternatively, download its three runtime files individually. If a release has no attached runtime assets, use the source-build instructions above. Do not install GitHub's automatic source archive as a built plugin.
First sync
Use a disposable project first. Enabling the plugin does not start syncing: all targets and auto-sync start off.
- Write a context note, or use AI Context Sync: Create AI context template note.
- Open it and run AI Context Sync: Set current note as AI context source.
- In plugin settings, add an existing absolute project directory and enable the targets you use.
~is not expanded. No implicit vault-root destination is selected. - Click Preview to validate the complete destination list without writing files.
- Click Sync now. Inspect the generated sections and confirm the surrounding instructions remain intact.
- Open a fresh assistant session and use its instruction/context diagnostics to check that it loaded the file. Test again after changing the source note.
- Optionally enable Auto-sync on save. It applies to future source edits, debounces for 500 ms, and takes effect without reloading the plugin. Turning it off cancels pending automatic writes.
The ribbon button and Sync AI context to enabled targets command perform a manual sync. Sync AI context to one enabled target limits a manual sync to one target across the configured projects.
How existing instructions are preserved
Given a manually authored CLAUDE.md, a sync appends this section:
# My existing project instructions
Keep these instructions.
<!-- ai-context-sync:begin -->
<!-- Context generated by AI Context Sync. Edit the Obsidian source note. -->
The contents of the selected Obsidian note.
<!-- ai-context-sync:end -->
Later syncs replace only the text between those marker lines, including the generated header. Text before and after the section stays unchanged. Edit the source note to change generated context; edit outside the markers for project-specific instructions. Malformed, duplicated, or embedded markers stop the sync rather than guessing what to replace. Source notes and headers cannot contain the reserved marker strings.
Cursor uses a dedicated .mdc rule with valid frontmatter and alwaysApply: true. An existing file at that exact path must have the plugin's header and markers; otherwise syncing stops. Other manual rules are left alone.
The optional header supports {{SOURCE}} and {{TIMESTAMP}}. Inserted source text is literal: dollar signs and template-looking text inside the note are not substituted. Timestamps are off by default so identical content does not create needless changes.
Destination and concurrency safeguards
- Project directories must already exist. A missing or mistyped root fails; required integration subdirectories are created only after validation.
- Symlink destinations and symlink parent directories inside a project are refused, including an
AGENTS.mdsymlink toCLAUDE.md. Hard-linked destination files are also refused. Disable the conflicting target or resolve its layout manually; the plugin does not alter those links. - Duplicate physical destinations, including aliases of one project directory, fail before any file is written. A source note cannot also be a destination.
- Targets have fixed paths. Old/custom output paths are not accepted from saved settings.
- Source reads and writes run through one ordered queue within the plugin. Files changed after planning are refused. Disabling auto-sync or unloading the plugin prevents queued automatic writes.
- Each changed file is replaced atomically. Existing regular-file permissions are preserved; new files are owner-readable/writable. A group of files is not one transaction: an I/O failure can leave earlier files updated. Review destinations and rerun after fixing the error.
Use a project directory you control. These checks are not an isolation boundary against another process changing filesystem paths at the same instant. Atomic replacement can change filesystem metadata such as extended attributes; store special filesystem metadata outside generated instruction files if you need to preserve it.
Upgrading from 1.0.0
Auto-sync is reset to off on upgrade. The source note and project directories are retained, and matching supported target selections are retained. The duplicate legacy Codex target becomes the single AGENTS target. Unsupported presets and custom per-target templates are removed from settings; existing exported files are never deleted or migrated automatically.
Version 1.0.0 did not use ownership markers. The plugin cannot identify which parts of an old export are yours. Review those files and remove obsolete generated text yourself before syncing. The old .cursor/rules/ai-context.md file is left untouched; the corrected rule uses ai-context-sync.mdc.
Disabling a target, removing a project, or uninstalling the plugin leaves generated sections in place. Remove a section from its begin marker through its end marker manually if you no longer want that context.
Validation and contributing
npm ci
npm run check
npm run release:prepare
npm run check runs regression tests, TypeScript checking, the production build, and a bundle syntax check. Tests use disposable temporary projects/vaults and a mocked Obsidian API. They cover instruction preservation, literal rendering, linked/duplicate destinations, changed-file refusal, live toggles, cancellation, and delayed reads. CI runs the same checks on Linux. No real vault or assistant configuration is used.
release:prepare additionally writes a ZIP, the three runtime files, and SHA-256 checksums under ignored dist/. It does not tag, upload, or publish anything.
Native Obsidian installation/UI behavior and fresh assistant ingestion still require a manual acceptance pass. If you report an issue, include plugin/Obsidian versions, the target, expected behavior, and a minimal disposable reproduction. Do not attach your private context note or credentials. Keep changes focused and add regression coverage for behavior you change.
License
MIT. Built by Mitch Tatge.
For plugin developers
Search results and similarity scores are powered by semantic analysis of your plugin's README. If your plugin isn't appearing for searches you'd expect, try updating your README to clearly describe your plugin's purpose, features, and use cases.