Back to Rules

🧠Replit Agent Rule: JavaScript Iteration and Runtime Feedback Excellence

OfficialPopular
ReplitJavaScript
replitjavascriptruntimedebuggingiterationbest-practices

Goal

Iterate fast using real execution and runtime feedback to validate JavaScript behavior and prevent hidden bugs.

Rule Behavior

1️⃣ Build by Running, Not Guessing

  • Execute code frequently to validate assumptions
  • Keep development loops tight: small change -> immediate output
  • Log expressive messages to observe behavior clearly
  • Fast feedback prevents complex bugs from forming

2️⃣ Simplicity First, Abstraction Later

  • Start with direct logic before refactoring
  • Improve structure only after behavior is verified
  • Prefer readability and predictability during iteration

3️⃣ Debugging as a Core Workflow

  • Treat runtime errors as valuable signals
  • Ask Agent to trace variable evolution through code
  • Avoid silent failures by monitoring state changes explicitly

4️⃣ Controlled Experiments

  • Create isolated snippets for high risk ideas
  • Validate external APIs and dependencies separately
  • Test edge cases before merging code into main modules

5️⃣ Server vs Client Clarity

  • Clearly specify environment context to the Agent
  • Do not mix DOM logic into Node.js or vice versa
  • Keep environment specific imports in the correct runtime

6️⃣ Runtime Safety

  • Validate and sanitize input from unknown sources
  • Review external library suggestions before use
  • Never run commands without understanding impact
  • Convenience must never override safe execution

7️⃣ Refactor With Behavioral Proof

  • Optimize naming and structure only after behavior is stable
  • Confirm old and new versions produce identical output
  • Introduce reuse only when duplication becomes consistent

Examples

  • "Run this snippet and show logs for every iteration step."
  • "Trace this variable and list state changes."
  • "Show the execution difference between Node and browser."

Tool Prompts

  • "Execute this code and explain unexpected output."
  • "Track variable values inside the loop."
  • "Simulate browser environment and show behavior."
  • "Check if this library is safe to import."

Quick Implementation Wins

  • Add clear console logs for loops and async code paths
  • Enable strict runtime checks in dev environment
  • Use isolated playground files for experimentation
View Tool Page