Cline rules
.clinerules/storage.mdCline rules
Quality
65/100
Scores the file, not the repository.Length
316 words
9 headings · 2 code blocksRepository
66k
— · pushed 0 days agoLast changed
3 days ago
First indexed 3 days ago.1# Storage Architecture23Global settings, secrets and workspace state are stored in **file-backed JSON stores** under `~/.cline/data/`. This is the shared storage layer used by VSCode, CLI, and JetBrains.45## Key Abstractions67### `StorageContext` (src/shared/storage/storage-context.ts)8The entry point. Created via `createStorageContext()` and passed to `StateManager.initialize()`. Contains three `ClineFileStorage` instances:9- `globalState` → `~/.cline/data/globalState.json`10- `secrets` → `~/.cline/data/secrets.json` (mode 0o600)11- `workspaceState` → `~/.cline/data/workspaces/<hash>/workspaceState.json`1213### `ClineFileStorage` (src/shared/storage/ClineFileStorage.ts)14Synchronous JSON key-value store backed by a single file. Supports `get()`, `set()`, `setBatch()`, `delete()`. Writes are atomic (write-then-rename).1516### `StateManager` (src/core/storage/StateManager.ts)17In-memory cache on top of `StorageContext`. All runtime reads hit the cache; writes update cache immediately and debounce-flush to disk.1819## ⚠️ Do NOT Use VSCode's ExtensionContext for Storage2021**Do not** read from or write to `context.globalState`, `context.workspaceState`, or `context.secrets` for persistent data. These are VSCode-specific and not available on CLI or JetBrains.2223Instead, use:24```typescript25// Reading state26StateManager.get().getGlobalStateKey("myKey")27StateManager.get().getSecretKey("mySecretKey")28StateManager.get().getWorkspaceStateKey("myWsKey")2930// Writing state31StateManager.get().setGlobalState("myKey", value)32StateManager.get().setSecret("mySecretKey", value)33StateManager.get().setWorkspaceState("myWsKey", value)34```3536Remember that your data may be read by a different client than the one that wrote it. For example, a value written by Cline in JetBrains may be read by Cline CLI.3738## VSCode Migration (src/hosts/vscode/vscode-to-file-migration.ts)3940On VSCode startup, a migration copies data from VSCode's `ExtensionContext` storage into the file-backed stores. This runs in `src/common.ts` before `StateManager.initialize()`.4142- **Sentinel**: `__vscodeMigrationVersion` key in global state and workspace state — prevents re-migration.43- **Merge strategy**: File store wins. Existing values are never overwritten.44- **Safe downgrade**: VSCode storage is NOT cleared, so older extension versions still work.4546## Adding New Storage Keys47481. Add to `src/shared/storage/state-keys.ts` (see existing patterns)492. Read/write via `StateManager` (NOT via `context.globalState`)503. If adding a secret, add to `SecretKeys` array in `state-keys.ts`5152## File Layout5354```55~/.cline/56 data/57 globalState.json # Global settings & state58 secrets.json # API keys (mode 0o600)59 tasks/60 taskHistory.json # Task history (separate file)61 workspaces/62 <hash>/63 workspaceState.json # Per-workspace toggles64```65
Also in cline/cline
Diff this repo’s formatsOne repository carrying more than one format is the comparison this product exists for: does anyone actually write different content in each file, or is one a copy of the other?
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| cline/cline.clinerules/bun-and-node.md · 66k | Cline rules | setuptestmonorepodo-not | 74/100 | 3 days ago | |
| cline/cline.clinerules/cline-overview.md · 66k | Cline rules | archtypesapi | 54/100 | 3 days ago | |
| cline/cline.clinerules/debug-harness.md · 66k | Cline rules | buildtesttesting-strategysecurity+1 | 85/100 | 3 days ago | |
| cline/cline.clinerules/general.md · 66k | Cline rules | setupbuildstylearch+2 | 86/100 | 3 days ago | |
| cline/cline.clinerules/network.md · 66k | Cline rules | styletesting-strategydependencies | 54/100 | 3 days ago | |
| cline/cline.clinerules/protobuf-development.md · 66k | Cline rules | buildstylearchapi+1 | 74/100 | 3 days ago | |
| cline/cline.clinerules/sdk-migration.md · 66k | Cline rules | style | 59/100 | 3 days ago | |
| cline/cline.github/copilot-instructions.md · 66k | Copilot instructions | buildteststyleapi+1 | 75/100 | 3 days ago | |
| cline/clineAGENTS.md · 66k | AGENTS.md | buildtestlint-formatstyle+2 | 83/100 | 3 days ago | |
| cline/clinesdk/AGENTS.md · 66k | AGENTS.md | setupbuildteststyle+5 | 89/100 | 3 days ago | |
| cline/clinesdk/packages/llms/AGENTS.md · 66k | AGENTS.md | no sections | 45/100 | 3 days ago |
Diff against .clinerules/bun-and-node.md Diff against .clinerules/cline-overview.md Diff against .clinerules/debug-harness.md Diff against .clinerules/general.md Diff against .clinerules/network.md Diff against .clinerules/protobuf-development.md Diff against .clinerules/sdk-migration.md Diff against .github/copilot-instructions.md Diff against AGENTS.md Diff against sdk/AGENTS.md Diff against sdk/packages/llms/AGENTS.md
Similar configs
Same format, overlapping stack, ranked by quality.
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| bashdeban/fastmind.clinerules/.project-consistency-keeper2.md · 5 | Cline rules | setupbuildtestlint-format+11 | 100/100 | 3 days ago | |
| JCodesMore/ai-website-cloner-template.clinerules · 31k | Cline rules | buildlint-formatstylearch+3 | 97/100 | 2 days ago | |
| BryaanF/LiantPortfolio.clinerules/project-guidelines.md · 0 | Cline rules | buildstylearchgit+2 | 96/100 | 3 days ago | |
| u9401066/zotero-keeper.clinerules/50-pubmed-project.md · 6 | Cline rules | testlint-formatstylearch+1 | 94/100 | 3 days ago | |
| u9401066/zotero-keepervscode-extension/resources/repo-assets/pubmed-search-mcp/.clinerules/50-pubmed-project.md · 6 | Cline rules | testlint-formatstylearch+1 | 94/100 | 3 days ago | |
| VaillerTeeter/HoshimiNest.clinerules/project-identity.md · 1 | Cline rules | setuparchtypesdo-not | 93/100 | yesterday | |
| HerringtonDarkholme/megarepo.clinerules/02-development.md · 17 | Cline rules | setupbuildteststyle+3 | 92/100 | 3 days ago | |
| blendsdk/codeops-mcp.clinerules/project.md · 0 | Cline rules | buildteststylearch+7 | 91/100 | 3 days ago |
