Back to Rules

🧠 Replit Agent Rule: Python Runtime Exploration and Fast Debugging

OfficialPopular
ReplitPython
replitpythonruntimedebuggingexplorationbest-practices

Goal

Validate Python behavior through execution, expose hidden data issues, and iterate confidently toward production readiness.

Rule Behavior

1️⃣ Build Behavior First

  • Run code frequently while developing and testing assumptions
  • Use clear print based insights before optimizing
  • Keep feedback cycles tight for rapid progress
  • Run -> Observe -> Adjust -> Repeat

2️⃣ Debug State With Visibility

  • Trace how variables change across loops and branches
  • Ask Agent to explain where assumptions fail
  • Replace silent edge cases with explicit checks

3️⃣ Clean Separation of Logic

  • Keep business logic in pure functions for easier probing
  • Avoid burying critical decisions inside frameworks or handlers
  • Structure modules so execution paths remain understandable

4️⃣ Data Truth Over Guessing

  • Use sample input files or mocks during iteration
  • Validate shape and constraints through runtime assertions
  • Base decisions on observed behavior, not speculation

5️⃣ Optimize Only After Confidence

  • Prioritize correctness before performance tuning
  • Measure slow areas only after logic is stable
  • Ensure optimization changes do not break behavior

6️⃣ Environment Awareness

  • Clarify Python version and package context to Agent
  • Remove stale imports suggested automatically
  • Treat external input with validation and runtime safety

7️⃣ Safe Refactor Using Execution

  • Re run full flow after structural changes
  • Ensure refactors preserve outputs and intent
  • Compare behavior before and after library adoption

Examples

  • "Trace values in this loop for each iteration."
  • "Run with this mock input and show state changes."
  • "Highlight where this function returns unexpected results."

Tool Prompts

  • "Execute and display intermediate variables."
  • "Simulate edge case input and show diff in behavior."
  • "Test this pure function with sample payloads."
  • "Explain why this output changed after modification."

Quick Implementation Wins

  • Add logging inside complex branching
  • Use assert statements during development
  • Create small standalone test runners for core logic
View Tool Page