Agent 4 keeps deleting important info in replit.md

I’ve been having a recurring issue with the new Agent 4. It keeps going into my replit.md file and deleting important information and notes written/created by Agent 3.

What used to be around 200 to 300 lines of content in the replit.md file is now reduced to around 40.
It deletes very important notes written by Agent 3 and are still relevant to my current web app and version.

It does this without me asking, and it’s pretty frustrating because I lose my project context and have to keep putting the info back in manually. I didn’t have this problem before the Agent 4 update, it used to leave those notes alone.

Is there a reason the new version is being so aggressive with that file? I’d really like to know if there’s a way to stop it from wiping out my work.

It also happened to me with agent 3 as well, so please go ahead and read through this thread for more context,
What? ”The replit.md file is automatically managed by Replit’s system”
**
But regardless of that, the current version of my replit.md document appears like this:

bIDMIO - Flask ERP System**

STOP: DO NOT MODIFY THIS FILE. This is a stable reference document. All detailed documentation lives in docs/. If you need to document changes, update docs/CHANGELOG.md, docs/GUARDRAILS.md, or the relevant docs/components/*.md file instead. NEVER add feature descriptions, architecture details, recent changes tables, or external dependency lists to this file.

Full Documentation: See docs/INDEX.md for complete navigation

Quick Start

# Start application

gunicorn -c gunicorn.conf.py main:app

# Start Celery worker (for notifications)

celery -A celery_app worker --loglevel=info

# Start Celery beat (for scheduled tasks)

celery -A celery_app beat --loglevel=info


Critical AI Agent Rules

MUST READ: See docs/GUARDRAILS.md for complete list

Date & Time Formatting

  • NEVER use raw .strftime() for display dates in templates

  • Use |company_date, |company_datetime, or |format_datetime_with_time filters

  • Exception: form value= attributes and JS data attributes may use .strftime('%Y-%m-%d')

  • Filters respect company timezone + date format settings (app/filters.py)

Translation System

  • Translation values MUST have status='active' (not ‘approved’)

  • Translation keys REQUIRE base_text_hash: md5(base_text)

  • Use _t('key', 'namespace') in templates

  • Restart workflow after seeding translations (cache)

Design System

  • NEVER use hardcoded colors — use var(--color-*)

  • NEVER add inline <style> blocks in templates

  • Use .ds-* component classes

  • Check /styleguide before creating components

Database

  • NEVER delete system tables: permission_groups, permissions, languages

  • All queries must be tenant-scoped (organization_id, company_id)

  • Use ORM for migrations, not raw SQL

File Storage

  • NEVER use local filesystem (static/uploads/) — files lost on deployment

  • Use Replit Object Storage via adapters/storage/app_storage.py

  • Serve files via /storage/{object_key} (handles auth + tenant check)

  • See docs/components/STORAGE.md for patterns

Performance & Caching

  • NEVER cache dynamic content (project data, work logs, calendars) in browser

  • Browser caching is for static files only (CSS, JS, fonts, images)

  • FLASK_ENV=production is set only in production environment (not shared)

  • See docs/architecture/PERFORMANCE.md for caching architecture

Startup Performance (CRITICAL)

  • NEVER modify main.py, routes/blueprint_registry.py, or gunicorn.conf.py for optimization

  • Deferred import patterns caused 3+ minute production startup — permanently excluded

  • See docs/GUARDRAILS.md > “Production Startup Performance” for safe alternatives

Stock Count Logic

  • NEVER modify stock count calculation logic — causes stocking issues

  • See docs/GUARDRAILS.md for details


User Preferences

  • Communication style: Simple, everyday language

  • Documentation: Detailed docs in docs/ folder, replit.md stays concise


Documentation Map

Document Purpose
docs/INDEX.md Complete documentation navigation
docs/GUARDRAILS.md Critical rules to prevent bugs
docs/CHANGELOG.md All changes with dates
docs/architecture/PERFORMANCE.md Caching, Redis fallback, profiling
docs/architecture/ARCHITECTURE_PRINCIPLES.md Clean code, SSOT, multi-tenancy
docs/architecture/DATABASE.md Schema, indexes, migrations
docs/architecture/CSS_ARCHITECTURE.md Design system, theming
docs/components/*.md Per-feature documentation
docs/guides/*.md Deployment, debugging, API guides