Exported functions in state/lib/notion.ts. .md file to compare - side-by-side diff against notion
notion
description: "Triggers on prompt mention of 'notion'."
What it does for you
Connects your assistant to your Notion workspace.
What it produces
A recent result, so you can see the kind of work it returns.
loading…
How to get it
These run inside the Snappy workspace. Want this working in your business? I set skills like this up with you, in one focused week.
For developers how this skill is built, graded, and how it runs
at a glance- the short version
what's inside - the parts that make up a skill 3/4 present
A skill is just a few plain-text files. Only the main one is required. The rest are optional, added as the work needs them. This is what the skill is made of; how it runs is just below.
state/skills/notion/SKILL.md
present
state/lib/notion.ts
present
state/bin/notion/
not present
state/skills/notion/AGENTS.md
present
how it's graded - what counts as a good run 5 criteria · 4 deterministic · 1 judge
Each row is one thing a good run has to get right. deterministic means a quick check decides, pass or fail. judge means the AI reads the result and rates it. Grading each piece on its own (instead of one overall score) shows exactly where a run fell short, so the fix is obvious.
how it runs - the shared frame every skill uses 4/5 present
Every skill runs the same way. One part does the work, a separate part checks it, and a short loader hands the AI exactly what it needs for the job. Anything this skill doesn't use shows a one-line note saying why, on purpose, not by accident.
This skill doesn't fix its own gaps yet.
state/log/pending-eval.ndjson what it has learned - fixes written back in over time sample
When a run hits something this skill didn't handle, the fix gets written back into the skill so it doesn't happen again. FIXED means it was corrected on the spot. LOGGED means it's queued for a bigger rewrite. Either way, the skill gets a little better and never makes the same mistake twice.
- Loading feedback rows…
how the work flows- who makes it, who checks it
import from `state/lib/notion.ts` - `search()`, `getPage()`, `createPage()`, `getBlockChildren()`, `appendBlocks()`, `queryDatabase()
SKILL.md- the skill, written out in plain English
notion
Notion REST capability: search, read pages, create pages, read and append blocks, and query databases.
Ported from kernel snappy-notion in Phase 0.5. See state/lib/notion.ts for the full API surface.
Steps
search()- seestate/lib/notion.tsgetPage()- seestate/lib/notion.tscreatePage()- seestate/lib/notion.tsgetBlockChildren()- seestate/lib/notion.tsappendBlocks()- seestate/lib/notion.tsqueryDatabase()- seestate/lib/notion.ts
Eval
Actor: the exported functions in state/lib/notion.ts. Auditor: none wired yet - eval is manual (Robert review). File a state/log/pending-eval.ndjson row on each run.
Score convention:
| Outcome | Score |
|---|---|
| Pass on first try | 1.0 |
| Failed first, auto-fix applied, re-check passed | 0.5 |
| Still failing or unrecoverable | 0.0 |
Gotchas
via the Phase 0.5 driver. Only these rewrites were applied: already in state/lib/)
realpathSync(process.argv[1])CLI guard wrapped in try/catch
- See the kernel SKILL.md for the original long-form guidance if you need it
(read-only reference at the kernel path above).
Eval policy
This skill is prose. Wire a deterministic auditor and set eval: auto to score it automatically.
Rubric
criteria:
- name: notion_result_nonzero
kind: deterministic
check: "Called function returns a non-empty result. search() returns {results: [...]}, array.length > 0. getPage/queryDatabase return object with id + properties. createPage returns {id, ...}."
- name: api_success_code
kind: deterministic
check: "HTTP response code is 200/201 (success). No 401/403 (auth), 429 (rate limit), or 5xx errors in the execution log."
- name: no_fallback_path
kind: deterministic
check: "Eval verb is NOT 'fallback'|'auth-failed'|'rate-limited'. Primary Notion API path was used (not local cache or degraded mode)."
- name: if_fallback_then_capped
kind: deterministic
check: "If auth/rate-limit causes fallback path, score is capped at 0.5 max regardless of fallback success."
- name: data_structure_valid
kind: judge
check: "Result schema matches Notion API docs. search results include object with title and block-type fields. Pages include properties object."AGENTS.md- what the AI loads when this skill comes up
notion - loader
Per-turn rules for the notion skill. Full reference: state/skills/notion/SKILL.md. Do not skip these.
Compound Response Pattern (MANDATORY)
When notion/notes intent fires, you MUST compose a structured surface - NOT flat prose.
Steps:
- Fetch recent pages via
state/lib/notion.ts:
npx tsx state/lib/notion.ts search "" --limit 10
Or import: search("") from state/lib/notion.ts (re-exports from state/lib/docs.ts).
- Compose via
compose_inline:
root = Card([
CardHeader("Notion - Recent"),
Stack([
Callout("Recently Edited", [...top 5 page titles as ListBlock items, or "No recent pages found"...]),
Callout("Databases", [...key databases found: projects, tasks, notes, etc...]),
Card([
TextInput("New Page Title", @Set($pageTitle, @Input)),
Button("Create Note", Mutation("invoke_skill_verb", {slug: "notion", verb: "create-page", apply: true, args: {title: $pageTitle}}))
])
]),
FollowUpBlock([
SnappyFollowUpItem("create a new note about today's work", "New note"),
SnappyFollowUpItem("search notion for [topic from context]", "Search Notion"),
SnappyFollowUpItem("summarize my project notes", "Summarize projects"),
])
])
$pageTitle = ""
- Always include FollowUpBlock even if pages are empty.
Critical Rules
_(no failures recorded yet - this skill is a Phase 0.5 mechanical port from snappy-notion with no hard-won rules. Marked LEGACY in the .md frontmatter - confirm the workflow actually needs Notion before reaching for this; most current substrate uses local files + Xano. Read state/skills/notion/SKILL.md and state/lib/notion.ts before invoking.)_
Commands
| ui model | live composition via compose_inline, persisted as artifact lang_body, reopened with OpenArtifact | |invoke: import from state/lib/notion.ts - search(), getPage(), createPage(), getBlockChildren(), appendBlocks(), queryDatabase() |eval log: state/log/pending-eval.ndjson (manual review until shape gate added)
Known Pitfalls
- Marked LEGACY - most workflows have moved off Notion. Verify the user actually wants Notion-targeted output before invoking
- Skill frontmatter says
eval: shapebut no auditor wired - log topending-eval.ndjson
Self-Test
An agent reading this should correctly:
- [ ] Question whether Notion is really the target before invoking (it's marked legacy)?
- [ ] Use
env("NOTION_TOKEN")(or whatever the lib expects) rather than bash credential fallback? - [ ] Log to
pending-eval.ndjsonbecause no shape auditor exists yet?
Found a gap? Edit this file. <!-- footer-injection-point -->
api.ts- the code it can call
#!/usr/bin/env npx tsx
/**
* snappy-notion/api.ts -- Legacy Notion skill. Re-exports from snappy-docs (canonical).
*
* Usage:
* npx tsx api.ts search <query>
* npx tsx api.ts page <id>
*
* Or import as module:
* import { search, getPage, createPage } from "./notion.ts";
*/
export { search, getPage, createPage, getBlockChildren, appendBlocks, queryDatabase } from "./docs.ts";
// Re-import for CLI usage
import { search, getPage } from "./docs.ts";
// --- CLI ---
if (import.meta.url === `file://${process.argv[1]}`) {
(async () => {
const [, , cmd, ...args] = process.argv;
switch (cmd) {
case "search": {
const query = args.join(" ");
if (!query) { console.error("Usage: api.ts search <query>"); process.exit(1); }
const data = await search(query);
for (const r of data.results) {
const title = r.properties?.title?.title?.[0]?.plain_text
|| r.properties?.Name?.title?.[0]?.plain_text
|| "(untitled)";
console.log(`${r.id}\t${r.object}\t${title}`);
}
break;
}
case "page": {
const [pageId] = args;
if (!pageId) { console.error("Usage: api.ts page <page_id>"); process.exit(1); }
const data = await getPage(pageId);
console.log(JSON.stringify(data, null, 2));
break;
}
default:
console.log("Usage: npx tsx api.ts [search|page] ...");
}
})();
}
scripts- helper scripts it can run
prose-only skill - 1 inline code block live in SKILL.md above (no state/bin/ sidecar yet).
how we check it- the checks, plus the last 10 runs
no recent runs logged - the eval contract is declared but nothing has been graded yet