Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
docs(fumadocs): document Twoslash patterns and SDK types
- Add reference docs exclusion documentation - Document SDK-exported modifier types (beforeExecuteModifier, afterExecuteModifier, TransformToolSchemaModifier) - Add declare pattern for external variables - Add troubleshooting tips for callback types - Update README with TypeScript code block validation section Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Sushmithamallesh committed
Jan 13, 2026 at 16:18 UTC
251f8b0bdfbd3c41396003e6bfe6e376209e38da
2 files changed
+50
-3
fumadocs/CLAUDE.md
+39
-2
@@ -51,11 +51,14 @@ CI auto-generates on changes to `ts/packages/core/src/**` or `python/composio/**
51
- **Build-time validation**: Type errors fail the build.
52
- **CI enforcement**: `.github/workflows/docs-typescript-check.yml` runs on PRs to fumadocs/
53
54
+### Exclusions
55
+- **Reference docs** (`/content/reference/`): Excluded from Twoslash via collection-level `mdxOptions` in `source.config.ts`. These are auto-generated and don't need type checking.
56
+
57
### Common patterns
58
59
**Basic snippet with setup code (hidden from output):**
60
````md
58
-```typescript twoslash
61
+```typescript
62
import { Composio } from '@composio/core';
63
const composio = new Composio({ apiKey: 'key' });
64
const userId = 'user_123';
@@ -65,7 +68,25 @@ const tools = await composio.tools.get(userId, { toolkits: ['GITHUB'] });
68
```
69
````
70
68
-**Skip type checking (for external deps or pseudocode):**
71
+**Using SDK-exported types for callbacks:**
72
+The SDK exports types for modifiers - use them instead of inline type annotations:
73
+````md
74
+```typescript
75
+import { Composio, TransformToolSchemaModifier } from '@composio/core';
76
+
77
+const modifySchema: TransformToolSchemaModifier = ({ toolSlug, toolkitSlug, schema }) => {
78
+ // TypeScript infers all parameter types!
79
+ return schema;
80
+};
81
+```
82
+````
83
+
84
+Available modifier types from `@composio/core`:
85
+- `beforeExecuteModifier` - for `beforeExecute` callbacks
86
+- `afterExecuteModifier` - for `afterExecute` callbacks
87
+- `TransformToolSchemaModifier` - for `modifySchema` callbacks
88
+
89
+**Skip type checking (for partial snippets or external deps):**
90
````md
91
```typescript
92
// @noErrors
@@ -73,6 +94,19 @@ import { SomeExternalThing } from 'not-installed-package';
94
```
95
````
96
97
+**Declare external variables in hidden section:**
98
+When code uses variables that aren't defined in the snippet, declare them before the cut:
99
+````md
100
+```typescript
101
+import { Composio } from '@composio/core';
102
+
103
+declare const composio: Composio;
104
+declare const userId: string;
105
+// ---cut---
106
+const tools = await composio.tools.get(userId, { toolkits: ['GITHUB'] });
107
+```
108
+````
109
+
110
### Annotations
111
- `// ---cut---` - Hide code above from output (but include for compilation)
112
- `// @noErrors` - Skip all type checking for this block
@@ -82,12 +116,15 @@ import { SomeExternalThing } from 'not-installed-package';
116
### Configuration
117
- **Config**: `source.config.ts` - `transformerTwoslash({ explicitTrigger: false })`
118
- **SDK packages**: Installed as devDependencies for import resolution
119
+- **Reference exclusion**: Uses `applyMdxPreset` with custom `rehypeCodeOptions` (no twoslash transformer)
120
121
### Troubleshooting
122
- If imports fail, ensure the package is in `devDependencies`
123
- Use `// @noErrors` for examples with external dependencies not in package.json
124
- Use `// ---cut---` to add setup code (imports, variable declarations) that compiles but isn't shown
125
- Check CI logs for specific error codes (e.g., 2304 = cannot find name, 2322 = type mismatch)
126
+- For callback types, prefer importing SDK types over inline `{ foo: string; bar: any }` annotations
127
+- Run `bun run build` locally to validate all code blocks before pushing
128
129
## Deployment
130
- Vercel project: `composio/fumadocs`
fumadocs/README.md
+11
-1
@@ -64,11 +64,21 @@ Each folder has `meta.json` for ordering:
64
}
65
```
66
67
+## TypeScript Code Blocks
68
+
69
+All TypeScript code blocks in MDX files are **type-checked at build time** using Twoslash. This ensures docs stay in sync with the SDK.
70
+
71
+- Use `// @noErrors` to skip checking for partial snippets
72
+- Use `// ---cut---` to hide setup code from output
73
+- Run `bun run build` locally to validate before pushing
74
+
75
+See `CLAUDE.md` for detailed patterns and troubleshooting.
76
+
77
## Commands
78
79
| Command | Description |
80
|---------|-------------|
81
| `bun run dev` | Dev server |
72
-| `bun run build` | Production build |
82
+| `bun run build` | Production build (validates TS code blocks) |
83
| `bun run types:check` | Type check |
84