Foam Notes
Work with Foam note-taking workspaces in VS Code. Foam is a free, open-source personal knowledge management system using standard Markdown files with wikilinks.
Quick Reference
- - Wikilinks:
[[note-name]] — connect notes bidirectionally - Embeds:
![[note-name]] — include content from other notes - Backlinks: Automatically discovered connections to current note
- Tags:
#tag or frontmatter INLINECODE3 - Daily Notes:
Alt+D or command "Foam: Open Daily Note"
Configuration
Copy config.json.template to config.json and edit to taste:
CODEBLOCK0
Location: config.json in the skill directory (next to SKILL.md).
Config keys
| Key | Type | Default | Description |
|---|
| INLINECODE9 | string | INLINECODE10 (auto-detect) | Path to your Foam workspace |
| INLINECODE11 |
string |
"new-note" | Template for new notes |
|
default_notes_folder | string |
"notes" | Subfolder for new notes |
|
daily_note_folder | string |
"journals" | Subfolder for daily notes |
|
author | string |
"" | Author name for note creation |
|
wikilinks.title_stopwords | list |
[] | Note titles to never match as wikilinks (e.g.
"home",
"index",
"todo"). Add any generic filenames from your workspace that produce false positives. |
|
wikilinks.suffixes | list |
[] | Filename suffixes whose base stem should also register as a match key. For example, if you name your hub/MOC notes
docker-hub.md, add
"-hub" here so that "docker" in prose matches
docker-hub.md. |
|
wikilinks.min_length | int |
3 | Minimum key length to consider for wikilink matching |
|
tags.editorial_stopwords | list |
[] | Domain-specific words to exclude from tag suggestions (in addition to standard English stopwords). |
Foam root priority order (highest to lowest)
- 1.
--foam-root CLI argument - INLINECODE34 environment variable
- INLINECODE35 in config.json
- Auto-detect by finding
.foam or .vscode directory - Current working directory
See references/configuration.md for complete documentation.
Scripts
All scripts support --foam-root to override the workspace path.
init_templates.py
Initialize .foam/templates/ with starter templates from the official Foam template:
CODEBLOCK1
Templates included:
- -
new-note.md — Default template for new notes - INLINECODE41 — Template for daily notes
- INLINECODE42 — Example template demonstrating VS Code snippets
create_note.py
Create a new note from template:
CODEBLOCK2
find_backlinks.py
Find all notes that link to a given note:
CODEBLOCK3
search_tags.py
Find notes by tag:
CODEBLOCK4
list_tags.py
List all tags with usage counts:
CODEBLOCK5
graph_summary.py
Analyze the knowledge graph:
CODEBLOCK6
daily_note.py
Create daily notes:
CODEBLOCK7
suggest_wikilinks.py
Suggest wikilinks by finding text in a note that matches existing note titles:
CODEBLOCK8
The script scans the note content and identifies words/phrases that match existing note titles in the archive. It presents them as a numbered list:
CODEBLOCK9
Wikilink formats:
- - Default:
[[target]] — clean, simple links - With
--with-aliases: [[target|display text]] — preserves original text as alias
Respond with:
- - Numbers to implement (e.g.,
1 3 5) - INLINECODE47 to apply all suggestions
- INLINECODE48 to cancel
suggest_tags.py
Suggest tags for a note based on content and existing tags in the archive:
CODEBLOCK10
The script:
- 1. Extracts keywords from note content
- Finds matching existing tags (with usage counts)
- Suggests new tags based on content analysis
Presented as numbered list with two sections:
- - Existing Tags — Already used in your archive
- New Suggestions — Extracted from current note content
Respond with:
- - Numbers (e.g.,
1 3 5) - INLINECODE50 — all suggestions
- INLINECODE51 — only existing tags
- INLINECODE52 — only new suggestions
- INLINECODE53 — cancel
- Or type custom tags: INLINECODE54
delete_note.py
Delete notes with optional backup and automatic backlink handling:
CODEBLOCK11
Features:
- - Backup mode: Moves note to
.foam/trash/ instead of permanent deletion - Backlink detection: Shows which notes link to the one being deleted
- Link fixing: Automatically removes wikilinks from other notes
- Confirmation: Prompts before deletion (skip with
--force)
rename_note.py
Rename notes and automatically update all wikilinks:
CODEBLOCK12
Features:
- - Automatic wikilink updates: Finds and updates all
[[old-name]] references - File rename: Changes filename from
old-name.md to INLINECODE59 - Title preservation: Keeps note content intact, only updates links
- Confirmation: Shows affected notes before proceeding
When to Use This Skill
Use this skill when:
- - Creating or editing notes in a Foam workspace
- Working with wikilinks, backlinks, or the knowledge graph
- Analyzing note relationships and connections
- Setting up or configuring Foam templates
- Working with daily notes or tags
- Publishing Foam workspaces to static sites
Foam Workspace Structure
CODEBLOCK13
Core Concepts
Wikilinks
Create connections between notes using double brackets:
CODEBLOCK14
- - Autocomplete with
[[ + type note name - Navigate with
Ctrl+Click (or Cmd+Click on Mac) - Create new notes by clicking non-existent links
- Link to sections: INLINECODE63
See references/wikilinks.md for complete documentation.
Backlinks
Backlinks show which notes reference the current note — discovered automatically by Foam.
Access via:
- - Command palette: "Explorer: Focus on Connections"
- Shows forward links, backlinks, or both
Use backlinks for:
- - Finding unexpected connections between ideas
- Identifying hub concepts (notes with many backlinks)
- Building context around ideas across domains
See references/backlinks.md for complete documentation.
Tags
Organize notes beyond wikilinks:
CODEBLOCK15
- - Hierarchical: INLINECODE64
- Browse in Tag Explorer panel
- Search: "Foam: Search Tag"
See references/tags.md for complete documentation.
Daily Notes
Quick daily journaling:
- - Shortcut: INLINECODE65
- Command: "Foam: Open Daily Note"
- Snippets:
/today, /yesterday, INLINECODE68
Template: INLINECODE69
See references/daily-notes.md for complete documentation.
Templates
Customize note creation. Foam looks for templates in .foam/templates/.
To initialize starter templates:
CODEBLOCK16
This copies official Foam templates to your workspace:
- -
new-note.md — Default template - INLINECODE72 — Daily notes template
- INLINECODE73 — Example with VS Code snippets
Markdown templates (.md):
CODEBLOCK17
JavaScript templates (.js) — for smart, context-aware templates.
See references/templates.md for complete documentation.
Common Tasks
Creating a New Note
When creating notes programmatically (not via VS Code), always read the workspace template in .foam/templates/new-note.md first and follow its structure exactly.
In VS Code:
- 1. Use "Foam: Create New Note" for default template
- Use "Foam: Create New Note From Template" to choose template
- Or click a non-existent wikilink INLINECODE77
Finding Note Relationships
- 1. Backlinks: Check Connections panel for linked notes
- Graph View: Command "Foam: Show Graph" for visual network
- Tag Explorer: Browse notes by tag
Working with Embeds
Include content from other notes:
CODEBLOCK18
Publishing
Foam can publish to static sites:
- - GitHub Pages (built-in template)
- Netlify
- Vercel
- GitLab Pages
- Custom static site generators (Gatsby, MkDocs, etc.)
See recipes in Foam documentation for publishing options.
Foam vs Obsidian
| Feature | Foam | Obsidian |
|---|
| Wikilinks | INLINECODE78 | INLINECODE79 |
| Embeds |
![[note]] |
![[note]] |
| Platform | VS Code | Dedicated app |
| Plugin ecosystem | Minimal (VS Code extensions) | Extensive |
| File format | Standard Markdown | Markdown with extensions |
| Configuration |
.vscode/settings.json |
.obsidian/ folder |
| Price | Free | Freemium |
Both use the same core linking syntax. Foam prioritizes simplicity and standard formats.
Configuration
Key .vscode/settings.json options:
CODEBLOCK19
Foam CLI Commands
Key VS Code commands:
- -
Foam: Open Daily Note — Create/open today's note - INLINECODE86 — Create from default template
- INLINECODE87 — Choose template
- INLINECODE88 — Create new template
- INLINECODE89 — Visualize knowledge graph
- INLINECODE90 — Search for tagged notes
- INLINECODE91 — Show backlinks panel
Reference Documentation
- - foam-overview.md — General Foam introduction and philosophy
- wikilinks.md — Complete wikilinks guide
- backlinks.md — Backlinks and knowledge discovery
- tags.md — Tag organization and filtering
- daily-notes.md — Daily note workflows
- templates.md — Template creation (Markdown and JavaScript)
Read these files for detailed information on specific features.
External Resources
- - Official site: https://foamnotes.com
- GitHub: https://github.com/foambubble/foam
- Discord: https://foambubble.github.io/join-discord/w
Tips
- 1. Start small: Foam works best with consistent note-taking habits
- Link liberally: Create wikilinks even to non-existent notes (placeholders)
- Use the graph: Visualize your knowledge network to find gaps
- Trust the process: Backlinks reveal connections you didn't plan
- Keep it standard: Foam uses standard Markdown — your notes remain portable
Foam 笔记
在 VS Code 中处理 Foam 笔记工作区。Foam 是一个免费、开源的个人知识管理系统,使用带有维基链接的标准 Markdown 文件。
快速参考
- - 维基链接:[[笔记名称]] — 双向连接笔记
- 嵌入:![[笔记名称]] — 包含其他笔记的内容
- 反向链接:自动发现与当前笔记的连接
- 标签:#标签 或 frontmatter tags: [标签1, 标签2]
- 日记:Alt+D 或命令 Foam: 打开日记
配置
将 config.json.template 复制为 config.json 并根据需要编辑:
json
{
foam_root: /path/to/your/foam-workspace,
default_template: new-note,
defaultnotesfolder: notes,
dailynotefolder: journals,
author: Your Name,
wikilinks: {
title_stopwords: [home, index, readme, draft, template],
suffixes: [-hub],
min_length: 3
},
tags: {
editorial_stopwords: [notes, note, foam, markdown, file, page, section]
}
}
位置:技能目录中的 config.json(与 SKILL.md 同级)。
配置键
| 键 | 类型 | 默认值 | 描述 |
|---|
| foamroot | 字符串 | (自动检测) | Foam 工作区的路径 |
| defaulttemplate |
字符串 | new-note | 新笔记的模板 |
| default
notesfolder | 字符串 | notes | 新笔记的子文件夹 |
| daily
notefolder | 字符串 | journals | 日记的子文件夹 |
| author | 字符串 | | 创建笔记的作者名称 |
| wikilinks.title_stopwords | 列表 | [] | 从不匹配为维基链接的笔记标题(例如 home、index、todo)。添加工作区中会产生误报的任何通用文件名。 |
| wikilinks.suffixes | 列表 | [] | 文件名后缀,其基本词干也应注册为匹配键。例如,如果您将中心/地图笔记命名为 docker-hub.md,请在此处添加 -hub,以便正文中的 docker 匹配 docker-hub.md。 |
| wikilinks.min_length | 整数 | 3 | 考虑进行维基链接匹配的最小键长度 |
| tags.editorial_stopwords | 列表 | [] | 从标签建议中排除的领域特定词(除了标准英语停用词之外)。 |
Foam 根目录优先级顺序(从高到低)
- 1. --foam-root CLI 参数
- FOAMWORKSPACE 环境变量
- config.json 中的 foamroot
- 通过查找 .foam 或 .vscode 目录自动检测
- 当前工作目录
完整文档请参见 references/configuration.md。
脚本
所有脚本都支持 --foam-root 来覆盖工作区路径。
init_templates.py
使用官方 Foam 模板中的入门模板初始化 .foam/templates/:
bash
python3 scripts/init_templates.py # 复制到当前工作区
python3 scripts/init_templates.py --foam-root ~/notes
python3 scripts/init_templates.py --list # 显示可用模板
python3 scripts/init_templates.py --force # 覆盖现有文件
python3 scripts/init_templates.py --dry-run # 预览将要复制的内容
包含的模板:
- - new-note.md — 新笔记的默认模板
- daily-note.md — 日记模板
- your-first-template.md — 演示 VS Code 代码片段的示例模板
create_note.py
从模板创建新笔记:
bash
python3 scripts/create_note.py 我的新想法
python3 scripts/create_note.py 会议笔记 --template meeting
python3 scripts/create_note.py 研究主题 --dir research/
find_backlinks.py
查找所有链接到给定笔记的笔记:
bash
python3 scripts/find_backlinks.py 机器学习
python3 scripts/find_backlinks.py ml-basics --format json
search_tags.py
按标签查找笔记:
bash
python3 scripts/search_tags.py #research
python3 scripts/search_tags.py machine-learning --include-frontmatter
list_tags.py
列出所有标签及其使用次数:
bash
python3 scripts/list_tags.py
python3 scripts/list_tags.py --hierarchy --min-count 3
graph_summary.py
分析知识图谱:
bash
python3 scripts/graph_summary.py
python3 scripts/graph_summary.py --format json
daily_note.py
创建日记:
bash
python3 scripts/daily_note.py
python3 scripts/daily_note.py --yesterday
python3 scripts/daily_note.py --template custom-daily
python3 scripts/daily_note.py --print-path # 仅输出路径
suggest_wikilinks.py
通过查找笔记中与现有笔记标题匹配的文本来建议维基链接:
bash
python3 scripts/suggest_wikilinks.py my-note.md # 交互模式
python3 scripts/suggest_wikilinks.py my-note.md --apply 1,3,5 # 自动应用
python3 scripts/suggest_wikilinks.py my-note.md --auto-apply # 全部应用
python3 scripts/suggest_wikilinks.py my-note.md --dry-run # 仅预览
python3 scripts/suggest_wikilinks.py my-note.md --with-aliases # 创建 [[目标|文本]] 格式
该脚本扫描笔记内容,识别与存档中现有笔记标题匹配的单词/短语。它以编号列表形式呈现:
- 1. 第12行,第8列
文本:machine learning
链接到:[[machine-learning]]
上下文:...working on machine learning projects...
维基链接格式:
- - 默认:[[目标]] — 简洁的链接
- 使用 --with-aliases:[[目标|显示文本]] — 保留原始文本作为别名
回复:
- - 要实施的数字(例如 1 3 5)
- all 应用所有建议
- none 取消
suggest_tags.py
根据内容和存档中的现有标签为笔记建议标签:
bash
python3 scripts/suggest_tags.py my-note.md # 交互模式
python3 scripts/suggest_tags.py my-note.md --apply all # 添加所有建议
python3 scripts/suggest_tags.py my-note.md --apply existing # 仅现有标签
python3 scripts/suggest_tags.py my-note.md --frontmatter # 添加到 frontmatter
该脚本:
- 1. 从笔记内容中提取关键词
- 查找匹配的现有标签(带使用次数)
- 基于内容分析建议新标签
以编号列表形式呈现,分为两个部分:
- - 现有标签 — 已在您的存档中使用
- 新建议 — 从当前笔记内容中提取
回复:
- - 数字(例如 1 3 5)
- all — 所有建议
- existing — 仅现有标签
- new — 仅新建议
- none — 取消
- 或输入自定义标签:#mytag #project
delete_note.py
删除笔记,支持可选备份和自动反向链接处理:
bash
python3 scripts/delete_note.py 旧笔记 # 交互式删除
python3 scripts/delete_note.py 旧笔记 --force # 跳过确认
python3 scripts/delete_note.py 旧笔记 --backup # 移动到 .foam/trash/
python3 scripts/delete_note.py 旧笔记 --fix-links # 从其他笔记中移除维基链接
功能:
- - 备份模式:将笔记移动到 .foam/trash/ 而不是永久删除
- 反向链接检测:显示哪些笔记链接到被删除的笔记
- 链接修复:自动从其他笔记中移除维基链接
- 确认:删除前提示(使用 --force 跳过)
rename_note.py
重命名笔记并自动更新所有维基链接:
bash
python3 scripts/rename