How It Works
The Dev Environment Agent runs when:- First task on a repository — No environment exists yet
- Environment failure detected — Existing setup has errors
What the Agent Analyzes
The agent examines your repository to understand:- Package manager — Lockfiles like
pnpm-lock.yaml,package-lock.json,poetry.lock - Framework — Next.js, Django, Rails, FastAPI, etc.
- Infrastructure —
docker-compose.yml, database requirements - CI/CD workflows — GitHub Actions, GitLab CI for environment hints
- Config files —
.env.example, framework configs, build scripts
The Bootstrap Process
The generated entrypoint script follows five phases:- System dependencies — Installs missing packages and version managers
- Project dependencies — Runs the appropriate install command for your package manager
- Infrastructure services — Starts Docker Compose and waits for healthy status
- Database setup — Runs migrations and seeds test data
- Development server — Starts your dev server in the background with logging
Self-Healing
If the environment fails—missing dependencies, crashed services, misconfigured databases—the Dev Environment Agent automatically diagnoses and fixes the issue. The SWE agent checks environment health before every task:- Reviews logs in
$TWILL_ENTRYPOINT_LOG_DIR - Looks for error indicators (failures, crashes, missing packages)
- Calls the Dev Environment Agent if problems are detected
- Proceeds with implementation only after environment is healthy
Learning and Persistence
Environment fixes aren’t throwaway. When the agent updates the configuration:- Changes are written to special files in the sandbox
- Twill detects and validates these updates
- New configuration is persisted to the database
- Future tasks use the improved environment
For complex or non-standard setups, you can always manually
configure the environment.