r/CLine • • 14h ago

Tutorial/Guide How I use Cline, and how I build the harness around it

Thumbnail
gallery
4 Upvotes

I'm building a local-first desktop app (Tauri + Svelte + SurrealDB). I don't expect Cline to just "be good". I give it a frame: rules, deterministic skills, a task tracker, ADRs and specs before code, quality gates, a context budget and session memory. The model matters, but the harness does the rest.

The project

VTT Data Manager Visuel (VTT-DMV) is a local-first desktop app for tabletop RPG game masters. It manages campaigns: the world, entities, relations, assets, tokens, players, dice and table tools.

The stack is :
Tauri v2 (Rust) for the backend,
Svelte 5 / SvelteKit for the UI,
embedded SurrealDB (surrealkv) for storage. The P2P layer over Steamworks is an additional layer, and optional in practice. All data stays on the user's machine.

Why describe the project? Because the project defines the needs, and therefore the Cline setup and the harness around it.

What the project needs (and why a harness)

Before talking tooling, we need to talk constraints. Here's what the project imposes:

- Local-first / privacy by design:
no cloud, no CDN, no telemetry.

- A complex, long-lived domain:
43 documented tables, architecture, ADRs and specs. The code has to stay correct six months from now.

- Non-negotiable quality:
unit, component and integration tests, `clippy -D warnings`, docs, WCAG accessibility, FR/EN i18n, light and dark themes.

- Traceability:
every change has to trace back to a ticket, a spec and an ADR.

- Context:
the codebase keeps growing, and an agent that reads everything blows the context window and "freezes".

- Reproducibility:
same conventions, same checks, same results, whatever the model (not exactly.. but... you know).

How I set up Cline in VS Code

In VS Code, I set up Cline around four ideas.

Always-loaded rules.
Four files (guardrails, workflow, documentation, traceability) carry the non-negotiables: architecture boundaries, error handling, commit conventions and the context budget. The model doesn't have to "remember" the rules, they're there from the start.

Deterministic skills.
I have 30 skills, one per domain: Rust, Svelte, SurrealDB and SurrealQL, testing, i18n, accessibility, repository pattern, ADRs and specs, security, and so on. A routing table (skills-map.tsv) maps a domain or a task label to the skills to load, a script (resolve-skills) resolves them, and each skill declares its linked skills. For example, Svelte pulls in i18n and accessibility, and SurrealDB pulls in SurrealQL and the repository pattern. A gate checks that no skill is orphaned.

Plan and Act, with reasoning effort.
I stay in Plan for design (ADRs, specs, Rust architecture), and switch to Act for mechanical edits. Reasoning effort is higher in Plan.

Memory outside the context.
I run a memory MCP server (MemPalace): a wake-up summary, a semantic search before answering about the past, and at the end of each ticket a drawer, a knowledge-graph fact and a diary entry. That way the project survives the context window.

The harness around it (adapting to the project)

Then I built a whole harness around Cline. This is the part that changed my day-to-day the most.

The plan lives in the tracker, not in the chat.
I drive tasks with Backlog.md on the CLI: acceptance criteria, definition of done, status transitions and a final summary. The agent reads the task first and writes the plan back into it. As a result, the next session doesn't start from a chat log.

The decision is documented before the code.
I don't implement anything before the ADR or the spec says what to build. When code and spec diverge, we fix one or the other in the same change. It's an active trade-off, not an automatic correction. And I'm the one who has to think through the consequences.

Quality gates are scripts.
make quality checks formatting, clippy, tests, docs, architecture invariants, schema and doc consistency, error-code i18n, duplication, traceability and Markdown links. A pre-commit hook runs a gate limited to staged files. The pre-push hook re-runs the full gate, but a tree fingerprint avoids running it twice. The agent can't "declare Done", the gate decides. I don't let the agent edit the gates on the fly. That's a working rule, not a technical lock yet, and it's something I want to improve.

The context budget is a first-class rule.
No verbose build or test without --quiet or redirection. Long outputs get filtered, big logs go to /tmp and I read the tail, and files are read by line ranges. That's what fixed my "Cline is stuck" moments.

Doc resolvers.
./scripts/vtt-docs (specs, ADRs, tickets), ./scripts/surreal-docs, ./scripts/svelte-docs and ./scripts/steamworks-docs: the agent reads the local docs instead of inventing syntax, especially SurrealQL, and it also picks up the frontend rules.

Documentation traceability.
A CHANGELOG in Keep a Changelog format, a roadmap split into three registers, numbered ADRs, specs, and a gate that checks the cross-links between ADRs, specs and the README.

The extra tooling

None of this is magic. These are standard tools, chosen to serve the quality loop.

On the Rust side, ts-rs generates the TypeScript contracts from the Rust types, so there's a single canonical source and versioned bindings. tokio, serde, toml, semver and uuid make up the base, and tempfile is used for isolated test databases. For the gates, I use cargo-nextest for fast tests, cargo-audit for security, clippy -D warnings and rustfmt.

On the frontend side, there's svelte-check, prettier, eslint, vitest for unit and component tests in a Chromium browser, playwright for real E2E, valibot for runtime validation of the IPC contracts, and Paraglide for compiled i18n.

For the workflow, there's Backlog.md on the CLI for tasks, a memory MCP server for the session, and make as the orchestrator, with one command: make quality.

A small note for the curious: cargo-nextest and cargo-audit are cargo subcommands installed globally, not dependencies in Cargo.toml.

Living documentation

The docs aren't a dead PDF. They're generated and checked like code.

The schema field inventory is generated from the code with gen-schema-fields.mjs --write. If the appendix is stale, the gate fails.

The ERD (.d2 to .svg) and the menu map are regenerated, and a gate checks that the code, the docs and the ERD agree.

The doc caches are built from the official docs (build-surrealdb-docs.sh, build-svelte-docs.sh, build-steamworks-docs.sh), and the CLIs return a path, not the content. That's a context saving.

Finally, ADRs, specs, the roadmap and the CHANGELOG are part of the workflow, and a gate (docs-traceability) checks the cross-links.

The result: when I change the schema, the docs get updated in the same change, or the gate fails. No docs rotting away.

The story that sums it up

Recently, an assistant proposed a ~250-line "write-ahead intent" to fix an atomicity problem between the database and a manifest file.

The harness did its job. The audit said "this isn't atomicity, it's compensation", the ADR laid out the options, and the conclusion was to remove the double write instead of adding a journal. The result: less code than before.

But that was only because I asked. I had to check what I suspected. The agent proposed an unsuitable solution because of a single word in the spec, interpreted as "atomicity is mandatory". The lesson isn't "write better prompts". It's that an ambiguous contract is enough to push the AI into over-engineering. The fix is an explicit spec, an audit and an ADR.

That's exactly what a setup built on rules, audits, ADRs and gates brings. It doesn't make the AI smarter. It stops it from shipping a bad solution.

Hosting and CI: Tangled

My `origin` remote isn't GitHub. It's Tangled (tangled.org), a decentralized git host built on the AT Protocol.

The CI lives in .tangled/workflows/ (backend, frontend, bench), and the logs are read over SSH with `ssh -t -p 3333 tangled.org did:plc:…`.

It's consistent with the project: local-first and decentralized on the product side, so also on the tooling side. It's not a technical requirement, just an ecosystem choice.

The result

In practice, here's what I get:

- less "it's going in circles", because the task, the skills, the gates and the context budget bound the work;

- fewer regressions, with ``make quality`` before pushing;

- traceable code, where every change is tied to a ticket, a spec or an ADR;

- and a simple takeaway: the model matters, but only for a small part. The harness does the rest.

What I want to improve: explore a context or doc cache, and add a real technical lock so the agent can't edit the gates.

hé voilà :D