DEV Community

Nova Elvaris
Nova Elvaris

Posted on

The One-File AI Workspace: How I Keep Context Across Sessions

Every morning I open a new AI chat and spend the first 10 minutes re-explaining my project. The architecture. The conventions. The decisions we already made yesterday.

Sound familiar?

I fixed this with a single markdown file. Here's the system.


The Problem

AI assistants have no memory between sessions. Every chat starts from zero. So you either:

  1. Re-explain everything (slow, error-prone)
  2. Paste a wall of context (expensive, noisy)
  3. Hope the AI figures it out (it won't)

None of these scale. You need a reusable context artifact.


The Solution: A Workspace File

Create one file called AI_CONTEXT.md\ in your project root:

# Project Context — [Project Name]

## What This Is
[1-2 sentences: what the project does, who it's for]

## Tech Stack
- Language: TypeScript
- Framework: Next.js 14 (app router)
- Database: PostgreSQL + Prisma
- Auth: NextAuth v5
- Hosting: Vercel

## Architecture Decisions
- Server components by default; client components only for interactivity
- All data fetching in server components (no useEffect)
- Zod schemas for all API input validation
- Feature folders: app/(feature)/page.tsx + components/ + lib/

## Naming Conventions
- Components: PascalCase
- Utilities: camelCase
- Database models: PascalCase (Prisma convention)
- API routes: kebab-case

## Current Focus
- Building the invoice module (CRUD + PDF generation)
- Due: end of this week

## Known Constraints
- Must work offline (PWA requirement)
- PDF generation happens server-side only
- Max invoice size: 100 line items
Enter fullscreen mode Exit fullscreen mode

How to Use It

Start every AI session with:

Read this project context, then help me with [task]:

[paste AI_CONTEXT.md contents]
Enter fullscreen mode Exit fullscreen mode

That's it. Three seconds of paste replaces ten minutes of explanation.


What to Put In (and What to Leave Out)

Include:

  • Tech stack and versions
  • Architecture decisions (the why, not just the what)
  • Naming conventions
  • Current sprint/focus area
  • Hard constraints (performance, compatibility, offline)

Exclude:

  • Full code listings (that's what file references are for)
  • Historical decisions you've moved past
  • Personal opinions on frameworks (the AI doesn't care)
  • Anything longer than 500 words total

The file should fit in one screen. If it doesn't, you're over-specifying.


Keeping It Fresh

The workspace file is a living document. Update it when:

  • You add a dependency
  • You make an architecture decision
  • You change your focus area
  • A constraint changes

I keep mine version-controlled with the project. The diff history becomes a record of project evolution.

My update rule: If I catch myself re-explaining something to the AI, it goes in the workspace file.


Advanced: Section-Based Context Loading

For larger projects, split context by domain:

project/
├── AI_CONTEXT.md          (global)
├── src/
│   ├── auth/
│   │   └── AI_CONTEXT.md  (auth-specific)
│   ├── billing/
│   │   └── AI_CONTEXT.md  (billing-specific)
Enter fullscreen mode Exit fullscreen mode

Then load only what's relevant:

Project context:
[paste global AI_CONTEXT.md]

Module context:
[paste billing/AI_CONTEXT.md]

Task: Add a "mark as paid" endpoint to the billing module.
Enter fullscreen mode Exit fullscreen mode

This keeps token usage low and context signal-to-noise high.


Real Impact

Before the workspace file:

  • ~10 min context setup per session
  • Frequent "that's not how we do it" corrections
  • Inconsistent naming across AI-generated code

After:

  • ~30 seconds (paste the file)
  • AI follows conventions from the start
  • Generated code matches existing patterns

Over a week, that's hours saved. Over a project, it's the difference between AI being useful and AI being a time sink.


The Template

Copy this, fill it in, drop it in your repo:

# Project Context — [Name]

## What This Is
[1-2 sentences]

## Tech Stack
- [Language + version]
- [Framework + version]
- [Database]
- [Key libraries]

## Architecture Decisions
- [Decision 1: why]
- [Decision 2: why]

## Naming Conventions
- [Pattern: rule]

## Current Focus
- [What you're building now]

## Known Constraints
- [Hard limits, deadlines, compatibility requirements]
Enter fullscreen mode Exit fullscreen mode

Takes 5 minutes to fill in. Pays for itself in the first session.


Do you use a context file for AI work? What sections did I miss? Let me know in the comments.

Top comments (0)