Skip to content

Turbocharge Claude Code, Cursor, Codex, Gemini & every coding agent: faster, cheaper, with contextual understanding specific to your codebase.

feat(hosts): canonical instruction body with per-host renderers

Shrish Dwivedi41a3754a1c60
diff --git a/src/hosts/instructions.ts b/src/hosts/instructions.ts
new file mode 100644
index 00000000..dcfc03ac
--- /dev/null
+++ b/src/hosts/instructions.ts
@@ -0,0 +1,47 @@
+/**
+ * The one canonical Graft instruction block, rendered into each host's
+ * native format. Content changes happen HERE only; renderers just wrap it.
+ */
+
+export function instructionBody(): string {
+ return `## Graft — repo context graph
+
+This repo is indexed in \`graft/\`: small linked markdown nodes that explain each
+system and carry exact file:line spans, kept in sync with the code through git.
+
+For ANY task here — understanding how something works, finding where code lives,
+or scoping a change — get context from the graph before grepping or opening
+source files:
+
+- Run \`graft ask "<your question>" --source\` → ranked nodes with the relevant
+ code spans inlined. The node usually IS the answer; stop there.
+- Or browse: \`graft/INDEX.md\` lists every node; follow the links.
+
+Only open source files when a node genuinely lacks a needed detail, and then at
+the exact file:line the node points to — never re-read whole files.
+
+After big code changes, refresh the graph with \`graft build\` (deterministic,
+no API key, $0).`;
+}
+
+export function cursorRule(): string {
+ return `---
+description: Use the Graft context graph in graft/ before exploring source
+alwaysApply: true
+---
+${instructionBody()}
+`;
+}
+
+export function kiroSteering(): string {
+ return `---
+inclusion: always
+---
+${instructionBody()}
+`;
+}
+
+export function windsurfRule(): string {
+ return `${instructionBody()}
+`;
+}
diff --git a/test/hosts-instructions.test.ts b/test/hosts-instructions.test.ts
new file mode 100644
index 00000000..3ae4659b
--- /dev/null
+++ b/test/hosts-instructions.test.ts
@@ -0,0 +1,28 @@
+import { test } from 'node:test';
+import assert from 'node:assert/strict';
+import { instructionBody, cursorRule, kiroSteering, windsurfRule } from '../src/hosts/instructions.js';
+
+test('canonical body names the three essentials', () => {
+ const b = instructionBody();
+ assert.match(b, /^## Graft — repo context graph/m);
+ assert.match(b, /graft ask "/);
+ assert.match(b, /graft\/INDEX\.md/);
+ assert.match(b, /graft build/);
+ assert.ok(!/\bhook|statusline\b/i.test(b), 'no host-specific machinery in the shared body');
+});
+
+test('cursor rule has alwaysApply frontmatter and the body', () => {
+ const r = cursorRule();
+ assert.match(r, /^---\ndescription: .+\nalwaysApply: true\n---\n/);
+ assert.ok(r.includes(instructionBody()));
+});
+
+test('kiro steering has inclusion: always frontmatter and the body', () => {
+ const r = kiroSteering();
+ assert.match(r, /^---\ninclusion: always\n---\n/);
+ assert.ok(r.includes(instructionBody()));
+});
+
+test('windsurf rule is the plain body', () => {
+ assert.ok(windsurfRule().includes(instructionBody()));
+});