Best practices
Agent rules & tips
Connecting the server gives your agent the tools — rules make it use them. MCP tool descriptions are suggestions; a rules file is read at the start of every session and is the reliable way to make memory recall habitual.
1. The rules block
Paste this into your agent's rules file. It encodes the full memory loop in nine lines — short enough to live in always-on context:
## AQL shared memory
You have access to AQL, a shared memory layer (MCP server "aql").
- START of any non-trivial task: call session_start, then search_problem
with the error message, symptom, or goal.
- Before writing code: call recall_skill if a relevant technique may exist.
- After solving a non-trivial problem: call document_solution with the
problem, the root cause, and the fix.
- Learned a reusable technique? learn_skill. A fact worth keeping?
store_insight.
- After recalling knowledge, report whether it helped: update_confidence.
- End of session: session_wrap_up.
- NEVER store secrets, tokens, private keys, or credentials in AQL.Where the file goes
| Client | Rules file |
|---|---|
| Claude Code | CLAUDE.md (project root) or ~/.claude/CLAUDE.md |
| Cursor | .cursor/rules/aql.mdc — or AGENTS.md |
| Windsurf | .windsurf/rules/ — or AGENTS.md |
| Codex | AGENTS.md (read natively) |
| Gemini CLI | GEMINI.md |
| GitHub Copilot | .github/copilot-instructions.md |
| Devin | AGENTS.md or a .devin/skills/ entry |
| Most other agents | AGENTS.md — the cross-vendor convention |
2. The memory loop
Every tool exists to serve one loop: hit a problem → search memory → apply → document the outcome.
- Recall before reasoning. A fix for a weird-looking error often already exists —
search_problemtakes seconds and can save the whole debugging session. - Store outcomes, not transcripts.
document_solutionshould carry the problem, the root cause, and the fix — not the whole conversation. - Score what you used.
update_confidenceis how good memory floats up and stale memory sinks. Skip it and ranking never improves. - Wrap up.
session_wrap_upchecks vault health and surfaces what was learned but not captured.
3. What is worth storing
- Non-obvious fixes — anything that took more than a few minutes to figure out: version quirks, undocumented flags, environment-specific failures.
- Project decisions — “we chose X over Y because Z” is the knowledge that is most expensive to lose and cheapest to store.
- Reusable techniques — workflows that worked once and will work again belong in
learn_skill. - Team knowledge — promote what the whole team needs via
share_to_team; the curated global wiki is readable by every user but writable only by admins.
4. What not to store
- Secrets. Never API keys, tokens, private keys, or passwords — in any scope. Global promotion additionally runs a secret/PII scrubber, but do not rely on it as a dump filter.
- Code that lives in git. Memory stores the why and the fix, not file contents the repo already has.
- Duplicated entries. Writes are idempotent by content hash — re-storing the same solution is a no-op, but rephrasing it creates near-duplicates that split confidence.