replit-advanced-troubleshooting
Debug hard Replit issues: container lifecycle, Nix build failures, deployment crashes, and memory leaks. Use when standard troubleshooting fails, investigating intermittent failures, or diagnosing complex Replit platform behavior. Trigger with phrases like "replit hard bug", "replit mystery error", "replit impossible to debug", "replit intermittent", "replit deep debug".
Best use case
replit-advanced-troubleshooting is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Debug hard Replit issues: container lifecycle, Nix build failures, deployment crashes, and memory leaks. Use when standard troubleshooting fails, investigating intermittent failures, or diagnosing complex Replit platform behavior. Trigger with phrases like "replit hard bug", "replit mystery error", "replit impossible to debug", "replit intermittent", "replit deep debug".
Teams using replit-advanced-troubleshooting should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/replit-advanced-troubleshooting/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How replit-advanced-troubleshooting Compares
| Feature / Agent | replit-advanced-troubleshooting | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Debug hard Replit issues: container lifecycle, Nix build failures, deployment crashes, and memory leaks. Use when standard troubleshooting fails, investigating intermittent failures, or diagnosing complex Replit platform behavior. Trigger with phrases like "replit hard bug", "replit mystery error", "replit impossible to debug", "replit intermittent", "replit deep debug".
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
Related Guides
AI Agents for Coding
Browse AI agent skills for coding, debugging, testing, refactoring, code review, and developer workflows across Claude, Cursor, and Codex.
Best AI Skills for Claude
Explore the best AI skills for Claude and Claude Code across coding, research, workflow automation, documentation, and agent operations.
ChatGPT vs Claude for Agent Skills
Compare ChatGPT and Claude for AI agent skills across coding, writing, research, and reusable workflow execution.
SKILL.md Source
# Replit Advanced Troubleshooting
## Overview
Deep debugging techniques for complex Replit issues that resist standard troubleshooting. Covers container lifecycle problems, Nix environment failures, deployment crash loops, memory leaks in constrained containers, and isolating Replit platform vs application issues.
## Prerequisites
- Shell access in Replit Workspace
- Understanding of Replit container lifecycle
- Ability to read deployment logs
- Familiarity with `.replit` and `replit.nix`
## Instructions
### Step 1: Systematic Issue Isolation
```bash
#!/bin/bash
set -euo pipefail
# replit-diagnose.sh — Layer-by-layer diagnosis
echo "=== Replit Diagnostic ==="
# Layer 1: Platform status
echo -n "1. Platform: "
curl -s https://status.replit.com/api/v2/summary.json | \
python3 -c "import sys,json;print(json.load(sys.stdin)['status']['description'])" 2>/dev/null || \
echo "UNKNOWN (check status.replit.com)"
# Layer 2: Nix environment
echo -n "2. Nix: "
if [ -f replit.nix ]; then
echo "configured"
nix-env -qaP 2>/dev/null | head -3 || echo "(nix-env not in path)"
else
echo "NO replit.nix found"
fi
# Layer 3: Runtime
echo -n "3. Node: "
node --version 2>/dev/null || echo "N/A"
echo -n " Python: "
python3 --version 2>/dev/null || echo "N/A"
# Layer 4: Dependencies
echo "4. Dependencies:"
npm list --depth=0 2>/dev/null | head -10 || echo " npm: N/A"
pip list 2>/dev/null | head -5 || echo " pip: N/A"
# Layer 5: Environment
echo "5. Environment:"
echo " REPL_SLUG=$REPL_SLUG"
echo " REPL_OWNER=$REPL_OWNER"
echo " NODE_ENV=${NODE_ENV:-unset}"
echo " DATABASE_URL=${DATABASE_URL:+SET}"
echo " REPLIT_DB_URL=${REPLIT_DB_URL:+SET}"
# Layer 6: Resource usage
echo "6. Resources:"
echo " Disk: $(df -h / 2>/dev/null | tail -1 | awk '{print $3 "/" $2 " (" $5 ")"}')"
echo " Memory: $(free -m 2>/dev/null | head -2 | tail -1 | awk '{print $3 "MB / " $2 "MB"}' || echo 'N/A')"
echo " Processes: $(ps aux 2>/dev/null | wc -l) running"
# Layer 7: Network
echo "7. Network:"
echo -n " replit.com: "
curl -s -o /dev/null -w "%{http_code} (%{time_total}s)\n" https://replit.com
echo -n " Database: "
if [ -n "${DATABASE_URL:-}" ]; then
node -e "const{Pool}=require('pg');new Pool({connectionString:process.env.DATABASE_URL,ssl:{rejectUnauthorized:false}}).query('SELECT 1').then(()=>console.log('OK')).catch(e=>console.log('FAIL:',e.message)).finally(()=>process.exit())" 2>/dev/null || echo "pg not installed"
else
echo "NOT CONFIGURED"
fi
```
### Step 2: Nix Build Failure Debugging
```bash
# When replit.nix changes cause build failures:
# 1. Check what channel provides
nix-env -qaP 2>/dev/null | grep nodejs
# Shows available Node.js package names
# 2. Common naming issues:
# pkgs.nodejs → WRONG (ambiguous)
# pkgs.nodejs-20_x → CORRECT
# pkgs.python3 → WRONG (use pkgs.python311)
# pkgs.python311 → CORRECT
# 3. Verify current channel
grep channel .replit
# channel = "stable-24_05" is current
# 4. After fixing replit.nix, reload shell:
# Exit Shell tab, re-enter it
# Or: exec $SHELL
# 5. If packages won't install, try clearing Nix cache:
# Remove generated Nix store symlinks
rm -rf .config/nixpkgs 2>/dev/null
```
### Step 3: Container Crash Loop Debugging
```markdown
When deployment keeps crashing and restarting:
1. Check deployment logs (Deployment Settings > Logs)
Look for:
- "JavaScript heap out of memory" → increase VM size or fix leak
- "Cannot find module" → dependency not installed in build step
- "EACCES" → file permission issue
- "EADDRINUSE" → port conflict
2. Test locally first:
- Click "Run" in Workspace
- Check Console tab for errors
- Fix before deploying
3. Isolate the crash:
```
```typescript
// Add to top of entry point — crash guard with logging
process.on('uncaughtException', (err) => {
console.error('UNCAUGHT EXCEPTION:', err.message);
console.error('Stack:', err.stack);
// Log the crash, then exit cleanly so Replit can restart
process.exit(1);
});
process.on('unhandledRejection', (reason: any) => {
console.error('UNHANDLED REJECTION:', reason?.message || reason);
console.error('Stack:', reason?.stack || 'no stack');
});
// Log startup time
const startTime = Date.now();
console.log(`Starting at ${new Date().toISOString()}`);
// ... your app code ...
app.listen(PORT, '0.0.0.0', () => {
console.log(`Started in ${Date.now() - startTime}ms on port ${PORT}`);
});
```
### Step 4: Memory Leak Detection
```typescript
// Replit containers have fixed memory limits. Detect leaks early.
const SAMPLE_INTERVAL = 30000; // 30 seconds
const samples: number[] = [];
setInterval(() => {
const heapMB = Math.round(process.memoryUsage().heapUsed / 1024 / 1024);
samples.push(heapMB);
// Keep last 60 samples (30 minutes)
if (samples.length > 60) samples.shift();
// Detect sustained growth
if (samples.length >= 10) {
const first5 = samples.slice(0, 5).reduce((a, b) => a + b) / 5;
const last5 = samples.slice(-5).reduce((a, b) => a + b) / 5;
const growth = last5 - first5;
if (growth > 50) { // 50MB growth over observation window
console.warn(`MEMORY LEAK SUSPECTED: +${growth.toFixed(0)}MB over ${samples.length * 30}s`);
console.warn(`Current: ${heapMB}MB, Samples: ${samples.length}`);
}
}
// Emergency: approaching container limit
if (heapMB > 450) { // Assuming 512MB container
console.error(`CRITICAL: Heap at ${heapMB}MB — approaching container limit`);
// Force garbage collection if available
global.gc?.();
}
}, SAMPLE_INTERVAL);
// Expose via health endpoint
app.get('/debug/memory', (req, res) => {
res.json({
current: process.memoryUsage(),
samples: samples.slice(-10),
trend: samples.length >= 2 ? samples[samples.length - 1] - samples[0] : 0,
});
});
```
### Step 5: Deployment vs Workspace Differences
```markdown
Common issues where code works in Workspace but fails in Deployment:
| Behavior | Workspace (Run) | Deployment |
|----------|-----------------|------------|
| Auth headers | NOT available | Available (X-Replit-User-*) |
| Database | Development DB | Production DB |
| Secrets | All visible | Auto-synced (2025+) |
| Filesystem | Persistent during session | Ephemeral (lost on restart) |
| Port | Any, mapped by Replit | Must use PORT env var |
| NODE_ENV | Usually unset | Set in .replit [env] |
Debugging steps:
1. Log process.env at startup to compare
2. Check if deployment has all required secrets
3. Verify build step produces correct output
4. Test with actual deployment URL, not Webview
```
### Step 6: Intermittent Failure Investigation
```typescript
// Track request patterns to find intermittent issues
const requestLog: Array<{
timestamp: number;
path: string;
status: number;
duration: number;
error?: string;
}> = [];
app.use((req, res, next) => {
const start = Date.now();
const originalEnd = res.end;
res.end = function (...args: any[]) {
const entry = {
timestamp: Date.now(),
path: req.path,
status: res.statusCode,
duration: Date.now() - start,
};
if (res.statusCode >= 400) {
(entry as any).error = (res as any)._errorMessage || 'unknown';
}
requestLog.push(entry);
if (requestLog.length > 1000) requestLog.shift();
return originalEnd.apply(res, args);
};
next();
});
// Debug endpoint — last 50 errors
app.get('/debug/errors', (req, res) => {
const errors = requestLog
.filter(r => r.status >= 400)
.slice(-50);
res.json({
totalRequests: requestLog.length,
errorCount: errors.length,
errors,
});
});
```
## Support Escalation
```markdown
When you need Replit support:
1. Collect: run replit-diagnose.sh
2. Document: steps to reproduce, expected vs actual
3. Screenshot: deployment logs, error messages
4. Submit: replit.com/support
Include:
- Repl URL (share link)
- Deployment URL
- Error messages (full text)
- When it started happening
- What changed before the issue
```
## Error Handling
| Issue | Cause | Solution |
|-------|-------|----------|
| Works locally, fails deployed | Missing build step or secret | Check build command and secrets |
| Intermittent 503 | Autoscale cold start | Switch to Reserved VM or add keepalive |
| Nix build infinite loop | Circular dependency | Simplify replit.nix, remove unused deps |
| Memory keeps growing | Leak in request handler | Profile with /debug/memory endpoint |
| Container won't start | Crash on import | Add crash guards, check dependency versions |
## Resources
- [Replit Support](https://replit.com/support)
- [Replit Status](https://status.replit.com)
- [Replit Community](https://ask.replit.com)
- [Nix on Replit](https://docs.replit.com/programming-ide/nix-on-replit)
## Next Steps
For load testing, see `replit-load-scale`.Related Skills
windsurf-advanced-troubleshooting
Advanced Windsurf debugging for hard-to-diagnose IDE, Cascade, and indexing issues. Use when standard troubleshooting fails, Cascade produces consistently wrong output, or investigating deep configuration problems. Trigger with phrases like "windsurf deep debug", "windsurf mystery error", "windsurf impossible to fix", "cascade keeps failing", "windsurf advanced debug".
vercel-advanced-troubleshooting
Advanced debugging for hard-to-diagnose Vercel issues including cold starts, edge errors, and function tracing. Use when standard troubleshooting fails, investigating intermittent failures, or preparing evidence for Vercel support escalation. Trigger with phrases like "vercel hard bug", "vercel mystery error", "vercel intermittent failure", "difficult vercel issue", "vercel deep debug".
supabase-advanced-troubleshooting
Deep Supabase diagnostics: pg_stat_statements for slow queries, lock debugging with pg_locks, connection leak detection, RLS policy conflicts, Edge Function cold starts, and Realtime connection drop analysis. Use when standard troubleshooting fails, investigating performance regressions, debugging race conditions, or building evidence for Supabase support escalation. Trigger: "supabase deep debug", "supabase slow query", "supabase lock contention", "supabase connection leak", "supabase RLS conflict", "supabase cold start".
snowflake-advanced-troubleshooting
Apply advanced Snowflake debugging with query profiling, spill analysis, lock contention, and performance deep-dives using ACCOUNT_USAGE views. Use when standard troubleshooting fails, investigating slow queries, or diagnosing warehouse performance issues. Trigger with phrases like "snowflake hard bug", "snowflake slow query debug", "snowflake query profile", "snowflake spilling", "snowflake deep debug".
shopify-advanced-troubleshooting
Debug complex Shopify API issues using cost analysis, request tracing, webhook delivery inspection, and GraphQL introspection. Trigger with phrases like "shopify hard bug", "shopify mystery error", "shopify deep debug", "difficult shopify issue", "shopify intermittent failure".
sentry-advanced-troubleshooting
Advanced Sentry troubleshooting for complex SDK issues, silent event drops, source map failures, distributed tracing gaps, and SDK conflicts. Use when events silently disappear, source maps fail to resolve, traces break across service boundaries, or the SDK conflicts with other libraries like OpenTelemetry or winston. Trigger with phrases like "sentry events missing", "sentry source maps broken", "sentry debug", "sentry not capturing errors", "sentry tracing gaps", "sentry memory leak", "sentry sdk conflict".
salesforce-advanced-troubleshooting
Apply Salesforce advanced debugging with debug logs, SOQL query plans, and EventLogFile analysis. Use when standard troubleshooting fails, investigating SOQL performance issues, or analyzing Apex governor limit violations. Trigger with phrases like "salesforce hard bug", "salesforce debug log", "salesforce governor limit", "salesforce query plan", "salesforce deep debug", "SOQL slow".
retellai-advanced-troubleshooting
Retell AI advanced troubleshooting — AI voice agent and phone call automation. Use when working with Retell AI for voice agents, phone calls, or telephony. Trigger with phrases like "retell advanced troubleshooting", "retellai-advanced-troubleshooting", "voice agent".
replit-webhooks-events
Handle Replit deployment events, build Replit Extensions, and set up Agents & Automations. Use when integrating with Replit deployment lifecycle, building workspace extensions, or creating automated workflows with Replit Agent. Trigger with phrases like "replit webhook", "replit events", "replit extension", "replit automation", "replit notifications", "replit agent automation".
replit-upgrade-migration
Upgrade Replit Nix channels, migrate between database types, and update deployment targets. Use when upgrading Nix channel versions, migrating from Replit DB to PostgreSQL, switching deployment types, or updating system dependencies. Trigger with phrases like "upgrade replit", "replit nix upgrade", "migrate replit database", "replit version update", "replit channel update".
replit-security-basics
Apply Replit security best practices: Secrets management, REPL_IDENTITY tokens, Auth headers, and public Repl safety. Use when securing API keys, validating request identity, or auditing Replit security configuration. Trigger with phrases like "replit security", "replit secrets", "secure replit", "replit public safety", "replit identity token".
replit-sdk-patterns
Apply production-ready patterns for Replit Database, Object Storage, and Auth APIs. Use when implementing Replit integrations, structuring data access layers, or establishing team coding standards for Replit services. Trigger with phrases like "replit patterns", "replit best practices", "replit code patterns", "idiomatic replit", "replit SDK".