DEV Community

Cover image for Stop Rebuilding AI Context Every Session
ran li
ran li

Posted on

Stop Rebuilding AI Context Every Session

I built a stateful workspace system for AI coding workflows

After months of heavy AI-assisted development, I kept running into the same workflow problem:

Every AI session felt like a partial reset.

Even with good models,
the workflow itself was fundamentally stateless.

Whenever I:

  • restarted Cursor
  • switched chats
  • changed models
  • reopened VS Code
  • resumed work the next day

the AI would lose track of:

  • which files were actively evolving
  • what feature I was implementing
  • recent debugging progress
  • relevant Git changes
  • architectural direction
  • current workspace focus

So I kept rebuilding context manually.

Over and over.

The Real Problem Isn’t Just Memory

At first I thought this was only a memory problem.

But eventually I realized:

The deeper issue is missing workspace state.

Most AI tools only understand isolated prompts or chat history.

Real software development depends on constantly evolving state:

  • active files
  • recent edits
  • changing priorities
  • debugging flow
  • Git activity
  • unfinished implementation context

That state changes continuously during development.

And most AI systems lose it between sessions.

Building Contorium

So I started building Contorium:
a persistent workspace state system for AI coding.

Instead of relying entirely on prompts,
Contorium continuously tracks workspace evolution and generates structured development context.

It tracks things like:

  • active editors
  • recently modified files
  • Git changes
  • current focus
  • workspace summaries
  • event history
  • compressed context memory
  • evolving file priority

All stored locally inside:

.contora/

The goal is simple:

Help AI understand the current state of development.

Not just remember old conversations.

Stateful AI Coding

One of the biggest shifts for me was realizing that AI coding workflows should probably behave more like state machines than chat sessions.

The system continuously updates:

  • what is actively changing
  • what matters most
  • where development is currently focused
  • which files are unstable
  • what recently evolved

That state can survive:

  • IDE restarts
  • session changes
  • model switches
  • multi-day workflows

This makes AI interactions feel far less disposable.

Git-aware Context Tracking

Git turned out to be one of the strongest context signals.

Contorium automatically tracks:

  • modified files
  • staged files
  • working tree changes
  • recent activity

Instead of dumping entire repositories into prompts,
the system prioritizes what is actively evolving.

This becomes especially useful in:

  • monorepos
  • long refactors
  • large AI-assisted codebases

Reducing Context Noise

Another issue I kept seeing:

Most AI workflows waste tokens on irrelevant context.

So Contorium also focuses heavily on:

  • file ranking
  • context compression
  • semantic summaries
  • noisy path filtering
  • compact workspace exports

The idea is not simply “more context.”

It’s:
better context prioritization.

Local-first Architecture

I intentionally designed the system as local-first.

No cloud workspace sync.
No hidden telemetry.
No chat scraping.

Optional BYOK providers currently include:

  • OpenAI
  • Claude
  • Gemini
  • DeepSeek

But the workspace state itself belongs to the developer.

Current Stack

Current stack includes:

  • TypeScript
  • VS Code Extension API
  • Cursor support
  • Claude Code / MCP support
  • local workspace scanners
  • structured context builders
  • Git-aware ranking systems

Current Direction

Right now I’m exploring:

  • stateful AI coding workflows
  • persistent development sessions
  • long-running agent systems
  • token-efficient context generation
  • AI-native development environments

I increasingly think persistent workspace state will become a standard layer in future AI IDEs.

Still early.
But already extremely useful in my own workflow.

Website:
https://www.contorium.dev

Top comments (0)