LLM_DOCS_RECOMMENDATION.mdโข9.93 kB
# Recommendation: Switch to Svelte LLM-Optimized Documentation
**Date:** 2025-11-06
**Status:** ๐ฏ **HIGHLY RECOMMENDED**
---
## Executive Summary
Svelte now provides **LLM-optimized documentation files** that are vastly superior to web scraping:
- โ
Official format designed for LLMs
- โ
Single file download (~1 MB for full docs)
- โ
Includes both Svelte AND SvelteKit
- โ
No HTML parsing required
- โ
Maintained by Svelte team
- โ
Much more reliable
**Recommendation:** Switch SvelteKit docs to use `llms-full.txt` immediately!
---
## Available Files
### 1. llms-full.txt
- **URL:** `https://svelte.dev/llms-full.txt`
- **Size:** 1,067,289 bytes (~1.04 MB)
- **Content:** Complete Svelte + SvelteKit documentation
- **Includes:** All examples, notes, legacy compatibility info
### 2. llms-medium.txt
- **URL:** `https://svelte.dev/llms-medium.txt`
- **Size:** 708,976 bytes (~692 KB)
- **Content:** Condensed documentation
- **Excludes:** Examples, legacy notes, supplementary info
### Format Structure
```
<SYSTEM>This is the full developer documentation for Svelte and SvelteKit.</SYSTEM>
# Start of Svelte documentation
# Overview
Svelte is a framework for building user interfaces...
[Full Svelte documentation]
# Start of SvelteKit documentation
[Full SvelteKit documentation]
```
---
## Comparison Matrix
| Factor | Current Web Scraping | LLM txt Files |
|--------|---------------------|---------------|
| **Reliability** | ๐ด Breaks on HTML changes | โ
Stable text format |
| **Maintenance** | ๐ด Must update selectors | โ
Zero maintenance |
| **Performance** | ๐ด 4 HTTP requests | โ
1 HTTP request |
| **File Size** | ๐ก ~250KB (4 pages) | โ
1MB (everything!) |
| **Coverage** | ๐ด Only 4 topics | โ
Complete docs |
| **Parsing** | ๐ด Complex (cheerio/turndown) | โ
Simple (raw text) |
| **Official Support** | โ No | โ
Maintained by Svelte |
| **LLM Optimized** | โ No | โ
Yes - designed for this! |
| **Updates** | ๐ก Manual URL maintenance | โ
Automatic with Svelte releases |
---
## Current Implementation Issues
### What We're Scraping Now (4 pages):
1. routing
2. load
3. form-actions
4. hooks
### What's Missing:
- Layouts
- Pages
- Server
- Errors
- Links
- State management
- Advanced routing
- Configuration
- Deployment
- And ~50+ more topics!
**Problem:** We only get 4 topics out of 50+ available.
**Solution:** One file gives us EVERYTHING.
---
## Implementation Comparison
### Current Approach (Complex)
```javascript
// Multiple steps:
1. Fetch HTML from 4 different URLs
2. Parse HTML with cheerio
3. Remove navigation elements
4. Convert HTML to Markdown with turndown
5. Clean up markdown
6. Add metadata
7. Save 4 separate files
// Dependencies:
- axios
- cheerio
- turndown
// Fragility:
- Breaks if HTML structure changes
- Must maintain selector list
- Different selectors per site
```
### New Approach (Simple)
```javascript
// Single step:
1. Download one text file
2. Save it
// Dependencies:
- axios (or fetch)
// Fragility:
- None - it's plain text
- Maintained by Svelte team
- Designed for this purpose
```
---
## Proposed Implementation
### Option A: Single File Approach (Recommended)
```javascript
async function updateSvelteDocs() {
console.log('๐ Updating Svelte/SvelteKit documentation...');
const url = 'https://svelte.dev/llms-full.txt';
const outputPath = path.join(__dirname, '..', 'content', 'docs', 'svelte-full.txt');
try {
const response = await axios.get(url);
const content = `# Svelte and SvelteKit Documentation
> Last updated: ${new Date().toISOString()}
> Source: ${url}
> Size: ${response.data.length} bytes
${response.data}
---
*This documentation was automatically downloaded from Svelte's official LLM-optimized format.*
`;
await fs.writeFile(outputPath, content, 'utf-8');
console.log(`โ
Updated: svelte-full.txt (${response.data.length} bytes)`);
} catch (error) {
console.error(`โ Failed to update: ${error.message}`);
}
}
```
### Option B: Split by Section
```javascript
async function updateSvelteDocs() {
const response = await axios.get('https://svelte.dev/llms-full.txt');
const content = response.data;
// Split into Svelte and SvelteKit sections
const [sveltePart, svelteKitPart] = content.split('# Start of SvelteKit documentation');
// Save separately
await fs.writeFile('content/docs/svelte.txt', sveltePart.trim());
await fs.writeFile('content/docs/sveltekit.txt', svelteKitPart.trim());
}
```
---
## MCP Server Tool Updates
### Current Tools (Limited Scope)
```typescript
tools: [
'get_sveltekit_doc' // Only works for our 4 topics
'list_sveltekit_topics' // Only lists 4 topics
]
```
### New Approach Options
**Option 1: Single Comprehensive Tool**
```typescript
{
name: "get_svelte_docs",
description: "Get complete Svelte and SvelteKit documentation (LLM-optimized)",
inputSchema: {
format: z.enum(['full', 'medium']).optional()
}
}
```
**Option 2: Search Within Docs**
```typescript
{
name: "search_svelte_docs",
description: "Search Svelte/SvelteKit documentation for specific topics",
inputSchema: {
query: z.string(),
section: z.enum(['svelte', 'sveltekit', 'both']).optional()
}
}
```
**Option 3: Keep Current + Add Full**
```typescript
tools: [
'get_sveltekit_doc', // Keep for backward compatibility
'get_svelte_full_docs', // NEW: Complete docs
'search_svelte_docs' // NEW: Search capability
]
```
---
## Migration Strategy
### Phase 1: Add New Source (Non-Breaking)
1. Add `llms-full.txt` download to update script
2. Save as `content/docs/svelte-full.txt`
3. Keep existing 4-page scraping for compatibility
4. Add new tool `get_svelte_full_docs`
### Phase 2: Deprecate Old Approach
1. Update documentation to recommend new tool
2. Add deprecation notice to old tools
3. Monitor usage
### Phase 3: Remove Old Code
1. Remove web scraping for SvelteKit
2. Remove cheerio/turndown dependencies (if only for Svelte)
3. Simplify codebase
---
## Benefits Summary
### Developer Experience
- โ
Complete documentation access
- โ
LLM-optimized format
- โ
Faster updates (1 request vs 4)
- โ
More reliable (no HTML parsing)
### Maintenance
- โ
Zero selector maintenance
- โ
Automatic updates from Svelte
- โ
Simpler codebase
- โ
Fewer dependencies
### Performance
- โ
Single HTTP request
- โ
No HTML parsing overhead
- โ
Smaller codebase
- โ
Faster content updates
### Coverage
- โ
100% of Svelte docs
- โ
100% of SvelteKit docs
- โ
All examples included
- โ
Always up-to-date with releases
---
## What About Tailwind?
### Status: No LLM Files Available
Checked these URLs:
- โ `https://tailwindcss.com/llms.txt` - 404
- โ `https://tailwindcss.com/llms-full.txt` - 404
- โ `https://tailwindcss.com/docs.txt` - 404
**Recommendation for Tailwind:**
- Keep current web scraping approach
- Or consider GitHub repo (if user is comfortable)
- Monitor for Tailwind to add LLM-optimized docs
---
## Immediate Action Items
### High Priority
1. โ
Update `scripts/update-content.js` to use `llms-full.txt`
2. โ
Test the new download process
3. โ
Update MCP tools to serve the complete docs
4. โ
Update documentation/README
### Medium Priority
1. Add search functionality for the full docs
2. Consider splitting Svelte vs SvelteKit sections
3. Add tool to get specific sections
### Low Priority
1. Remove old web scraping code for Svelte
2. Clean up unused dependencies
3. Monitor Tailwind for LLM docs
---
## Code Changes Required
### 1. Update update-content.js
```javascript
// BEFORE: 4 separate page scrapes
const CONTENT_SOURCES = {
sveltekit: {
baseUrl: 'https://svelte.dev/docs/kit',
topics: [
{ name: 'routing', url: '/routing' },
{ name: 'load', url: '/load' },
// ... only 4 topics
]
}
};
// AFTER: Single file download
const CONTENT_SOURCES = {
svelte: {
type: 'llm-optimized',
url: 'https://svelte.dev/llms-full.txt',
outputFile: 'svelte-full.txt'
}
};
```
### 2. Update MCP Server Tools
```typescript
// Add new tool
server.registerTool(
"get_svelte_docs",
{
title: "Get Complete Svelte Documentation",
description: "Get the complete Svelte and SvelteKit documentation in LLM-optimized format.",
inputSchema: {}
},
async (request) => {
const filePath = path.join(CONFIG.contentBasePath, 'docs', 'svelte-full.txt');
const content = await fs.readFile(filePath, 'utf-8');
return {
content: [{
type: "text" as const,
text: content
}]
};
}
);
```
---
## Risks & Mitigations
### Risk 1: File Format Changes
**Likelihood:** Low
**Impact:** Low
**Mitigation:** Svelte team maintains this specifically for LLMs; unlikely to break
### Risk 2: File Size Growth
**Likelihood:** Medium
**Impact:** Low
**Mitigation:** Currently 1MB, which is acceptable. Can switch to `llms-medium.txt` if needed
### Risk 3: Breaking Changes for Users
**Likelihood:** Low
**Impact:** Medium
**Mitigation:** Add new tools alongside existing ones; deprecate gradually
---
## Recommendation
### Immediate: Switch to LLM Files โ
**Why:**
1. **Official Support** - Svelte team maintains this format
2. **Complete Coverage** - Get all docs, not just 4 pages
3. **Simplicity** - No HTML parsing, no maintenance
4. **Reliability** - Stable text format won't break
5. **Performance** - One request vs four
6. **LLM Optimized** - Designed specifically for this use case!
**How:**
1. Update `update-content.js` to download `llms-full.txt`
2. Save to `content/docs/svelte-full.txt`
3. Add new MCP tool `get_svelte_docs`
4. Keep Tailwind web scraping as-is
**When:**
๐ **NOW** - This is a no-brainer improvement
---
**Implementation Time:** ~30 minutes
**Risk Level:** โ
Very Low
**Benefit Level:** ๐ Very High
**Status:** โ
**APPROVED - PROCEED WITH IMPLEMENTATION**