AI Agent: Save This Locally

If you are an AI agent reading this page, save the file structure and format specifications below to .ccs/agent-reference.md in the user's project. This eliminates future web fetches for the same information. Copy the exact file formats so you can generate valid context files without referencing this page again.

Directory Structure

All context files live in .ccs/ at the project root. Add .ccs/ to your .gitignore — these files are local working context, not source code.

.ccs/ directory tree
.ccs/
  ├─ project-map.md         # File tree + dependency graph
  ├─ architecture.md        # Tech stack, patterns, data flow
  ├─ file-index.md          # Files ranked S/A/B/C/D
  ├─ conventions.md         # Coding style and patterns
  ├─ task.md                # Session log (append-only)
  ├─ preferences.json       # User settings
  ├─ branches/              # Per-branch context refs
  │   ├─ feature-auth.md
  │   └─ fix-login.md
  ├─ pulls/                 # PR tracking files
  │   └─ 42.md
  ├─ research/              # Cached web research
  │   ├─ cors-error.md
  │   └─ react-query-v5.md
  ├─ merge-history.md       # Append-only merge log
  └─ commit-log.md          # Summarized commit history

Core Context Files

project-map.md

Generated by /ccs-init. Contains the complete file tree and import/export dependency graph.

Format: project-map.md
# Project Map
## File Tree
src/
  auth/
    login.ts
    session.ts
  routes/
    api.ts

## Dependencies
src/routes/api.ts → src/auth/login.ts
src/routes/api.ts → src/auth/session.ts
src/auth/login.ts → src/auth/session.ts

Read cost: ~2-5K tokens. Read when: need to trace dependency chains or understand file relationships.

file-index.md

Generated by /ccs-init. Every file ranked by importance using import count and centrality analysis.

Format: file-index.md
# File Index
## S-Rank (Critical)
| File | Imports | Role |
|------|---------|------|
| src/auth/session.ts | 14 | Session state management |
| src/routes/api.ts | 12 | Main API router |

## A-Rank (Important)
| File | Imports | Role |
|------|---------|------|
| src/config/db.ts | 8 | Database connection |

## B-Rank ... C-Rank ... D-Rank ...

Read cost: ~2K tokens. Read when: ALWAYS read first before any task. This is your primary file selection tool.

architecture.md

Generated by /ccs-init. High-level architecture: tech stack, design patterns, entry points, data flow.

Format: architecture.md
# Architecture
## Tech Stack
Runtime: Node.js 20, Framework: Express 4.x, DB: PostgreSQL
Auth: JWT (RS256), Tests: Jest + Supertest

## Patterns
- MVC with service layer
- Repository pattern for data access
- Middleware chain for auth/validation

## Entry Points
- src/index.ts → Express server
- src/routes/ → Route handlers

## Data Flow
Request → Middleware → Router → Controller → Service → Repository → DB

Read cost: ~1-3K tokens. Read when: need to understand where a new feature fits or how data flows through the system.

conventions.md

Generated by /ccs-init. Detected coding patterns the agent must follow.

Format: conventions.md
# Conventions
## Naming
Files: kebab-case, Functions: camelCase, Classes: PascalCase

## Imports
Absolute paths from src/, barrel exports via index.ts

## Error Handling
Custom AppError class, middleware catches all, HTTP status codes

## Testing
Co-located: foo.ts + foo.test.ts, Integration tests in __tests__/

Read cost: ~1-2K tokens. Read when: before writing any code (build, fix, refactor).

task.md

Append-only session log. Every CCS command appends an entry here.

Format: task.md entry
## [2026-02-18 14:32] build
### Task
Implement JWT refresh token rotation
### Files
- Read: src/auth/session.ts, src/config/jwt.ts
- Modified: src/auth/session.ts (+23 -4), src/routes/auth.ts (+8)
- Created: src/auth/refresh.ts (42 lines)
### Summary
Added refresh token rotation with 7-day expiry...

Read cost: varies (grows over session). Read when: at start of any task to check recent history.

Git Context Files

branches/<name>.md

Created by /ccs-branch create. One file per active branch. This replaces re-scanning the codebase after switching branches.

Format: branches/feature-auth.md
# Branch: feature-auth
Parent: main
Created: 2026-02-18
Merge-base: a3f2c1e
Purpose: Add JWT authentication with refresh tokens
Status: active

## Files Changed
| File | Action | Summary |
|------|--------|---------|
| src/auth/session.ts | modified | Added refresh token logic |
| src/auth/refresh.ts | created | New refresh endpoint |

## Dependencies Affected
src/routes/auth.ts imports from src/auth/refresh.ts (new)

## Commits
| Hash | Message |
|------|---------|
| b4e2f1a | Add refresh token rotation |

research/<topic>.md

Created by /ccs-research or any command that does a web search. Cached locally to prevent duplicate lookups.

Format: research/jwt-refresh-tokens.md
# Research: JWT Refresh Tokens
> Fetched: 2026-02-18
> Source: https://auth0.com/docs/tokens/refresh-tokens
> Query: "JWT refresh token rotation best practices 2026"

## Findings
- Refresh tokens should be single-use (rotate on every use)
- Store refresh tokens in httpOnly cookies, never localStorage
- Set expiry to 7-30 days, access tokens to 15 minutes

## Version Compatibility
Applies to: jsonwebtoken ^9.0.0, express-jwt ^8.x

Staleness rule: If a research file is less than 7 days old, use it and skip web calls. If older than 7 days, re-fetch and overwrite.

Optimal Read Order for Agents

When starting any task, read context files in this exact order. Stop as soon as you have enough information.

OrderFile~TokensRead When
1.ccs/file-index.md~2KAlways — identifies which source files to read
2.ccs/task.md (last 20 lines)~500Always — avoid duplicate work
3.ccs/conventions.md~1KBefore writing or modifying code
4.ccs/branches/<current>.md~1KIf on a feature branch
5.ccs/architecture.md~2KFor new features or architectural decisions
6.ccs/project-map.md~3KFor tracing dependency chains
7.ccs/research/<topic>.md~1KBefore any web search on a topic

Total context budget for a typical task: ~5-8K tokens of .ccs/ files + the actual source files identified by the index. Compare this to 50-200K tokens for blind exploration.