Setting up an MCP pre-coding search routine means configuring your Claude Code environment so the agent searches documentation and API references before generating code, preventing hallucinated imports and outdated API calls. By adding the Scavio MCP server and a CLAUDE.md instruction, you create a workflow where Claude Code verifies package versions, reads changelogs, and checks API signatures against live search data before writing a single line.
Prerequisites
- Claude Code installed and configured
- Scavio API key from scavio.dev
- A project directory with CLAUDE.md
Walkthrough
Step 1: Configure the Scavio MCP server
Add the Scavio MCP server to your project so Claude Code can call search tools.
cat > .mcp.json << 'MCPEOF'
{
"mcpServers": {
"scavio": {
"url": "https://mcp.scavio.dev/mcp",
"headers": {
"Authorization": "Bearer YOUR_SCAVIO_API_KEY"
}
}
}
}
MCPEOFStep 2: Add pre-coding search instructions to CLAUDE.md
Write instructions in your CLAUDE.md that tell Claude Code to search before coding. This creates the automatic pre-coding search routine.
cat >> CLAUDE.md << 'EOF'
## Pre-Coding Search Routine
Before writing code that uses an external library or API:
1. Search for the current version: "[library name] latest version 2026"
2. Search for the API signature: "[library name] [function] API reference"
3. If the library was updated in the last 6 months, search for migration guides
4. Verify import paths match the current version
Do NOT rely on training data for:
- Package versions or install commands
- API endpoint URLs or authentication methods
- Configuration file formats
- CLI flag syntax
EOFStep 3: Add domain-specific search rules
Extend the routine with project-specific rules that target the frameworks and APIs your team uses.
cat >> CLAUDE.md << 'EOF'
## Project-Specific Search Rules
Always verify before using:
- Next.js: search "next.js [feature] app router" (not pages router)
- Stripe: search "stripe api [endpoint] 2026" (API changes frequently)
- Prisma: search "prisma [method] latest" (ORM syntax varies by version)
- AWS SDK: search "aws sdk v3 [service]" (v2 is deprecated)
EOFStep 4: Test the routine
Open Claude Code and give it a task that requires external API knowledge. Verify it searches before coding.
# In Claude Code, try:
# 'Add Stripe checkout to this Next.js app'
#
# Expected behavior:
# 1. Claude searches 'stripe checkout api next.js 2026'
# 2. Claude searches 'next.js server actions stripe'
# 3. Claude writes code using verified API signatures
#
# Without the routine, Claude might use:
# - Deprecated Stripe API methods
# - Pages router patterns instead of App Router
# - Wrong import paths from outdated training dataPython Example
# Generate the MCP config and CLAUDE.md programmatically
import json, os
def setup_pre_coding_routine(project_dir, api_key, frameworks=None):
# Write MCP config
mcp_config = {
'mcpServers': {
'scavio': {
'url': 'https://mcp.scavio.dev/mcp',
'headers': {'Authorization': f'Bearer {api_key}'}
}
}
}
mcp_path = os.path.join(project_dir, '.mcp.json')
with open(mcp_path, 'w') as f:
json.dump(mcp_config, f, indent=2)
# Append search routine to CLAUDE.md
routine = '''
## Pre-Coding Search Routine
Before writing code that uses an external library or API:
1. Search for the current version
2. Search for the API signature or reference docs
3. Check for recent breaking changes or migration guides
4. Verify import paths match the current version
'''
if frameworks:
routine += '\n## Framework-Specific Rules\n'
for fw in frameworks:
routine += f'- {fw}: always search "{fw} latest API" before using\n'
claude_md_path = os.path.join(project_dir, 'CLAUDE.md')
with open(claude_md_path, 'a') as f:
f.write(routine)
print(f'MCP config written to {mcp_path}')
print(f'Search routine appended to {claude_md_path}')
setup_pre_coding_routine('.', 'YOUR_API_KEY', ['Next.js', 'Stripe', 'Prisma'])JavaScript Example
const fs = require('fs');
function setupPreCodingRoutine(projectDir, apiKey, frameworks = []) {
const mcpConfig = {
mcpServers: {
scavio: {
url: 'https://mcp.scavio.dev/mcp',
headers: {Authorization: \`Bearer \${apiKey}\`}
}
}
};
fs.writeFileSync(\`\${projectDir}/.mcp.json\`, JSON.stringify(mcpConfig, null, 2));
let routine = \`
## Pre-Coding Search Routine
Before writing code that uses an external library or API:
1. Search for the current version
2. Search for the API signature or reference docs
3. Check for recent breaking changes
4. Verify import paths match the current version
\`;
if (frameworks.length) {
routine += '\n## Framework-Specific Rules\n';
frameworks.forEach(fw => {
routine += \`- \${fw}: always search "\${fw} latest API" before using\n\`;
});
}
fs.appendFileSync(\`\${projectDir}/CLAUDE.md\`, routine);
console.log('MCP config and search routine configured');
}
setupPreCodingRoutine('.', 'YOUR_API_KEY', ['Next.js', 'Stripe', 'Prisma']);Expected Output
MCP config written to .mcp.json
Search routine appended to CLAUDE.md
Claude Code now searches docs and API references before writing code.