LoopX: How to Run Codex and Claude Code on Multi-Day Projects Without Losing Context
You’re running Codex CLI on a refactoring project. Day one goes great — the agent makes solid progress. Day two, you restart the session and… it forgets everything. The objective drifts. Evidence from yesterday is gone. You’re back to square one.
LoopX fixes this. It’s an open-source state kernel that sits alongside your coding agent (Codex, Claude Code, Cursor, OpenCode) and maintains the durable context they need: objectives, gates, todos, evidence, quotas, and handoffs.
The Problem: Why Coding Agents Lose Context
Current AI coding agents are stateless between sessions. When you close Codex and reopen it tomorrow:
- Objectives drift — the agent doesn’t remember what you were actually trying to accomplish
- Evidence disappears — test results, error logs, and intermediate findings are lost
- No quota awareness — the agent keeps running even when no useful progress is possible
- Handoffs break — if multiple agents work on parts of the same project, they can’t coordinate
Chat history helps, but it’s not designed for multi-day engineering work. You need something that tracks what the goal is, what’s been proven, what’s blocked, and who should act next.
How LoopX Works: A Practical Example
Let’s say you’re using Codex to fix a bug across a large codebase. Here’s the flow:
Day 1: Start the goal
───────────────────────
loopx start-goal --guided --project . \
--goal-text "Fix the race condition in the payment processor"
Codex runs → finds 3 potential causes → writes evidence
LoopX saves: objective, findings, next todos
Day 2: Resume work
──────────────────
loopx connect
loopx status # Shows: 2/3 causes ruled out, 1 needs human review
Codex reads LoopX state → knows exactly where to continue
Agent asks: "Should I proceed with mutex approach or channel approach?"
Day 3: Finish
─────────────
Human answers gate question → Codex implements solution
LoopX records: evidence of fix, test results, PR link
The key insight: LoopX doesn’t replace your agent — it gives it memory that survives restarts.
Quick Start: 5 Minutes to First Goal
Requirements: Python 3.11+, macOS or Linux
# Install LoopX
curl -fsSL https://raw.githubusercontent.com/huangruiteng/loopx/main/scripts/install-from-github.sh | bash
export PATH="$HOME/.local/bin:$PATH"
# Verify installation
loopx doctor
# Connect to your project
cd /path/to/your-project
loopx connect
# Start a long-running goal
loopx start-goal --guided --project . --goal-text "Refactor auth module to use OAuth2"
# Check status anytime
loopx status
Connecting Your Coding Agent
With Codex App (Desktop)
Ask the agent:
“Connect this project to LoopX, run loopx doctor, preserve existing state, and show me the current gate and next todo.”
Then use $loopx <task> or pick loopx from /skills.
With Codex CLI
codex # Start in your project directory
Then tell the agent: “Connect to LoopX and continue the current objective.”
With Claude Code
Install the adapter, then:
/loopx <task>
/loop # Continue the current objective
With Cursor or OpenCode
Install the static command facade, use --with-goal-bridge for recurring goals.
Real-World Use Cases
Use Case 1: Multi-Day Bug Hunt
Scenario: You’re tracking down an intermittent crash that only happens under load.
loopx start-goal --project . \
--goal-text "Find and fix intermittent crash in order service under >1000 RPS"
Over 3 days:
- Day 1: Agent adds logging, identifies 5 suspect areas
- Day 2: Agent rules out 3 areas, needs production logs (gate: waiting on you)
- Day 3: You provide logs, agent identifies the issue, writes fix + test
LoopX tracks: hypothesis tree, ruled-out paths, evidence links, what’s still unknown.
Use Case 2: Large Refactoring Across Multiple Services
Scenario: You’re migrating from REST to gRPC across 4 microservices.
loopx start-goal --project /path/to/monorepo \
--goal-text "Migrate user-service, order-service, inventory-service, notification-service from REST to gRPC"
LoopX maintains:
- Completion status per service
- Shared proto definitions
- Migration evidence (which endpoints converted, which pending)
- Integration test results
Use Case 3: Autonomous Research/Benchmarking
Scenario: You want an agent to explore algorithm optimizations.
loopx auto-research "Improve k-NN search performance without changing accuracy"
LoopX runs a multi-agent loop:
- Proposer generates hypotheses
- Executor implements and tests each
- Evaluator promotes winners, prunes losers
- Narrator summarizes progress for you
All visible in the LoopX frontstage — not a black box.
Key Commands Reference
| Command | What It Does |
|---|---|
loopx connect | Link current directory to LoopX state |
loopx status | Show current objective, gates, todos, evidence |
loopx start-goal --guided | Begin a new long-running objective |
loopx doctor | Diagnose installation and state health |
loopx quota | Check remaining budget/tokens |
loopx gate answer | Respond to a human decision gate |
How It Differs From Other Tools
| Tool | What It Does | LoopX Difference |
|---|---|---|
| LangChain/LlamaIndex | Orchestrate LLM chains | LoopX is runtime-agnostic; works with any agent |
| Cursor/Codex | The coding agent itself | LoopX adds persistent state across sessions |
| Git | Version control for code | LoopX tracks agent state, not just code changes |
| Project management | Human task tracking | LoopX is agent-native; gates are executable |
FAQ
Does LoopX require an API key or subscription?
No. LoopX is fully open-source (MIT license) and runs locally. It doesn’t call external APIs — it manages state files in your project.
Can I use LoopX with my existing Codex/Claude Code workflow?
Yes. LoopX is additive. Install it, connect your project, and your agent can read/write LoopX state. Your existing workflow continues to work.
What happens if I don’t use LoopX for a few days?
Nothing breaks. LoopX state persists in .loopx/ in your project. When you resume, run loopx status to see where you left off.
Can multiple developers share LoopX state?
Yes. The .loopx/ directory can be committed to git (minus any sensitive evidence). Team members see the same objective, gates, and todos.
Does LoopX work with non-coding agents?
The design is coding-focused, but the state model (objectives, gates, todos, evidence) applies to any long-running agent work. Community adapters exist for research and ops workflows.
How does quota management work?
You set a token/cost budget when starting a goal. LoopX tracks usage and stops the agent when the budget is exhausted or no useful transition remains — preventing runaway spending.
Is my code sent anywhere?
No. LoopX runs entirely locally. It reads/writes state files in your project and interacts with your local agent. No telemetry except anonymous usage stats (version, OS, architecture), which you can disable with SIE_TELEMETRY_DISABLED=1.
When to Use LoopX
✅ Good fit:
- Multi-day engineering objectives
- Bug hunts requiring evidence tracking
- Refactoring across large codebases
- Work that requires human decision gates
- Multiple agents coordinating on one project
❌ Not needed:
- Quick one-shot tasks (“write a function that does X”)
- Single-session work
- Fully autonomous production systems (LoopX keeps humans in the loop)
Links
- GitHub: huangruiteng/loopx
- Documentation: huangruiteng.github.io/loopx/docs/
- Discord: discord.gg/XmGgQyCFZd
- User Manual (Feishu): Detailed walkthrough in Chinese/English
If you’re running Codex or Claude Code on anything that takes more than one session, LoopX is worth 5 minutes to try. The state persistence alone solves a real problem that no amount of prompt engineering can fix.