Skip to content

Smart Context settings

Smart Context exports a selection of notes (and optionally their linked notes) into a single, easy-to-use bundle you can paste into chat.

These settings control the format of that export by applying two layers of templates:

Where to find these settings in Obsidian

Open Settings -> Community plugins -> Smart Context .

Note

Templates only change the text you copy/export. They do not change your notes on disk.


How an context is structured

When you copy a context, Smart Context outputs one text blob that conceptually looks like:

  1. Context Template Before
  2. Repeated for each item:
    • Item Template Before
    • Item content (the note text)
    • Item Template After
  3. Context Template After

If you want reproducibility (stable prompts) or machine parsing, templates are the control surface.


Context templates

Context templates wrap the entire export.

Available variable

If you remove {{FILE_TREE}} from your Context Template Before/After, the export will not include the file tree.

Default (XML)

Template Before

<context>
{{FILE_TREE}}

Template After

</context>
Tip

Keep global wrappers short. Every extra character here repeats on every copy and costs tokens if you paste into an LLM.


Item templates

Item templates wrap each individual item (usually a note) in the export.

Available variables

{{LINK_DEPTH}} is most useful when you export with linked notes included:

Default (XML)

Template Before

<item loc="{{KEY}}" at="{{TIME_AGO}}" depth="{{LINK_DEPTH}}">

Template After

</item>

Template examples

Use these as starting points depending on how you use Smart Context.

1) Default (XML tags + attributes)

Context Template Before

<context>
{{FILE_TREE}}

Context Template After

</context>

Item Template Before

<item loc="{{KEY}}" at="{{TIME_AGO}}" depth="{{LINK_DEPTH}}">

Item Template After

</item>

Why this works:

2) Human-readable, LLM-friendly (minimal structure, low overhead)

Context Template Before

{{FILE_TREE}}

Context Template After: BLANK

Item Template Before

## {{KEY}} (updated {{TIME_AGO}})

Item Template After: BLANK

Why this works:

3) Diff-friendly separators (good for prompt reproducibility)

Context Template Before

{{FILE_TREE}}

====================
BEGIN CONTEXT
====================

Context Template After


====================
END CONTEXT
====================

Item Template Before

--------------------
FILE: {{KEY}}
UPDATED: {{TIME_AGO}}
DEPTH: {{LINK_DEPTH}}
--------------------

Item Template After: BLANK

Why this works:


Troubleshooting

"My file tree is missing"

Ensure {{FILE_TREE}} is present in either Context Template Before or Context Template After.

"I included linked notes but cannot tell which were pulled in"

Add depth="{{LINK_DEPTH}}" (or an equivalent line) to your Item Template Before so the depth is visible per item.

"My export is too long / too many tokens"

Related pages

Dataview (inline field '===================
END CONTEXT
===================='): Error: 
-- PARSING FAILED --------------------------------------------------

> 1 | ===================
    | ^
  2 | END CONTEXT
  3 | ====================

Expected one of the following: 

'(', 'null', boolean, date, duration, file link, list ('[1, 2, 3]'), negated field, number, object ('{ a: 1, b: 2 }'), string, variable