Replit.md template : replit_TripleGuard_template_en.md (click to download)
by Adam Chan
Note: Replit Agent, GitHub Copilot, Cursor, and other "LLM coding agents" are all similar tools, but Replit's integration is more comprehensive - it can directly run programs, install dependencies, and update file structures in the cloud container, and also provides specialized Edit Code and Explain Code modes to reduce error rates.
replit.md
is a "project black box notebook" placed in the project root directory specifically for Replit Agent to read and write⭐. It has three core functions:replit.md
(and other files at the same level like system_mapping_*.md
) into the prompt, allowing the model to understand the current architecture, route mapping, known bugs and other statuses before deciding what code to generate.replit.md
?system_mapping_routes.md
)In the Replit Builder community, many users treatreplit.md
as a "quick notes + AI prompt file," which is far more effective than verbal reminders
LLMs can patch code instantly like senior engineers, but they also tend to modify files they shouldn't touch like programming novices, unless someone—or some process—keeps them in check.
Break down typical error patterns, apply targeted solutions: Just by adding 3 steps before impulsive fixes—"scan, checkpoint, validate"—you can block 80% of AI misoperations.
Concept: Give AI a red line—"Only modify live code." Roll back if violated.
Concept: Enforce a three-phase process—
Checklist → Priority-based repair → Feature validation + Documentation update.
Concept: No trace point = No code changes; Missing trace points → Escalate to "Real Path Discovery."
Replit.md template : replit_TripleGuard_template_en.md (click to download)👉 The following items A) to D) contain Rules & Guidelines that I've tested and found effective for debugging tasks in adverse working environments with code refactoring or extensive legacy code. These guidelines help the Agent accurately complete debugging tasks without being confused by duplicate code. The content is already divided into sections; simply copy and paste it into yourreplit.md
to use. ("TripleGuard Debug Framework” is specifically designed as a lightweight debugging workflow for monolithic or small web projects deployed in a single environment, and it is not suited for distributed microservices architectures)
# E. Mandatory Confirmation of Actual Execution Path - Must be completed before any modifications
# Solves the "checkpoint tracking failure" problem - When code is modified but logs show no checkpoints
# E1. Global Route Mapping Scan
find . -name "*.ts" -o -name "*.js" | xargs grep -n "app\.(post|get|put|delete)" | grep -E "target endpoint"
# E2. Runtime Route Registration Confirmation
## Add forced mapping tracking in route registration file:
app._router?.stack?.forEach((middleware, index) => {
if (middleware.route) {
console.log(`
RUNTIME-ROUTE-${index}: ${middleware.route.path} [${Object.keys(middleware.route.methods)}]`); } }); # E3. Global Request Interceptor (Top-level Injection) app.use('*', (req, res, next) => { console.log(`
🚨 REQUEST-INTERCEPT: ${req.method} ${req.originalUrl} - Time:${Date.now()}`); next(); }); # E4. Response Header Reverse Confirmation Method ## Inject unique identifiers in all suspicious execution paths: res.setHeader('X-Execution-Path', 'filename:line number:function name'); res.setHeader('X-Debug-Timestamp', Date.now()); ## Frontend checks response headers to confirm actual execution location # E5. Execution Environment Consistency Check stat -c %Y target file.ts # Confirm file modification time ps aux | grep node # Confirm running processes
# F. Execution Path Multiple Validation - Prevents modifying incorrect code paths
# F1. Parallel Checkpoint Strategy
## Simultaneously add different checkpoint identifiers at all suspicious locations
## For example: TRACE-A, TRACE-B, TRACE-C
# F2. Complete Network Request Tracking
curl -v -X POST "http://localhost:port/api/target endpoint" \
-H "Content-Type: application/json" \
-d '{"test": "data"}' \
2>&1 | grep -E "(HTTP|X-Execution)"
# F3. Database Operation Reverse Inference Method
## Monitor database operations to infer actual execution path
SELECT * FROM pg_stat_activity WHERE query LIKE '%target operation%';
# F4. File System Monitoring
## Monitor file read/write to confirm execution path (Linux/Mac)
lsof -p $(pgrep node) | grep "target file"
# A. Key Functionality Global Search
find . -name "*.ts" -o -name "*.tsx" -o -name "*.js" -o -name "*.jsx" \
| xargs grep -l "key functionality name" 2>/dev/null
# B. Route/Endpoint Duplication Detection
find . -path "./node_modules" -prune -o \
-name "*.ts" -o -name "*.js" \
| xargs grep -n "app\.(get|post|put|delete)|router\.(get|post|put|delete)" 2>/dev/null
# C. Function Definition Duplication Detection
find . -path "./node_modules" -prune -o \
-name "*.ts" -o -name "*.tsx" -o -name "*.js" -o -name "*.jsx" \
| xargs grep -n "function.*key name|const.*key name.*=|export.*key name" 2>/dev/null
Command: "Execute Route Discovery Scan"
1. Scan all route definition files under server/
2. Start runtime route registration tracking
3. Record the actual call status of each endpoint (called/not called)
4. Establish active route list and dead route exclusion list
Command: "Execute Code File Classification Scan"
1. Scan top comments of all .ts/.tsx files
2. Identify REDUNDANT/DEPRECATED/BACKUP markers
3. Check file import/export relationships
4. Establish dead code list, duplicate functionality list, active code list
Command: "Establish Checkpoint Validation Mechanism"
1. Deploy unique identifier checkpoints at each suspicious execution location
2. Execute user operations to trigger actual execution paths
3. Record the actual sequence of executed checkpoints
4. Establish "verified execution" and "excluded non-execution" lists
Command: "Build Module Call Relationship Graph"
1. Track API call chain: frontend → route → business logic → database
2. Record data flow: user input → processing → storage → response
3. Establish dependency relationship matrix
You: Run Checklist
Agent: 〈Returns scan report + modification plan〉
You: OK
You: Fix According to Plan regenerate route duplication issue
Agent: 〈Inserts multi-path checkpoints, displays logs〉
You: OK
Agent: 〈Submits patch diff〉
You: Apply
You: Validate Then Confirm
Agent: 〈Runs tests → No errors → Updates replit.md〉
You: Execution Path Discovery regenerate