Mettre en place une routine de recherche pré‑codage MCP consiste à configurer votre environnement Claude Code pour que l’agent consulte la documentation et les références API avant de générer du code, évitant ainsi les imports hallucinés et les appels API obsolètes. En ajoutant le serveur MCP Scavio et une instruction dans CLAUDE.md, vous créez un flux de travail où Claude Code vérifie les versions des packages, lit les changelogs et contrôle les signatures API par rapport aux données de recherche en direct avant d’écrire la moindre ligne.
Prérequis
- Claude Code installé et configuré
- Clé API Scavio depuis scavio.dev
- Un répertoire de projet avec CLAUDE.md
Parcours
Étape 1: Configurer le serveur MCP Scavio
Ajoutez le serveur MCP Scavio à votre projet pour que Claude Code puisse appeler les outils de recherche.
cat > .mcp.json << 'MCPEOF'
{
"mcpServers": {
"scavio": {
"url": "https://mcp.scavio.dev/mcp",
"headers": {
"Authorization": "Bearer YOUR_SCAVIO_API_KEY"
}
}
}
}
MCPEOFÉtape 2: Ajouter des instructions de recherche pré‑codage dans CLAUDE.md
Rédigez des instructions dans votre CLAUDE.md qui demandent à Claude Code de rechercher avant de coder. Cela crée la routine de recherche pré‑codage automatique.
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
EOFÉtape 3: Ajouter des règles de recherche spécifiques au domaine
Étendez la routine avec des règles propres au projet qui ciblent les frameworks et API utilisés par votre équipe.
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)
EOFÉtape 4: Tester la routine
Ouvrez Claude Code et confiez‑lui une tâche nécessitant des connaissances API externes. Vérifiez qu’il effectue une recherche avant de coder.
# 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 dataExemple Python
# 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'])Exemple JavaScript
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']);Sortie attendue
MCP config written to .mcp.json
Search routine appended to CLAUDE.md
Claude Code now searches docs and API references before writing code.