Sessions & Project Memory
Save conversation histories locally and maintain persistent project memory across developer sessions.
KnightCode is designed to be local-first, keeping your conversation logs and project guidelines secure on your local machine.
SQLite Session Management
Every conversation you start in KnightCode is written to a local SQLite database file in your home directory.
- Switch Sessions: Run
/sessionsto browse, switch, or delete past conversation logs. - Rename Sessions: Run
/renameto give the active session a friendly name. - Fork Conversations: Run
/branchto copy the active conversation history into a new session.
Project Memory System
To avoid repeating project details, rules, or preferences in every session, KnightCode implements a persistent Project Memory system:
1. Guideline Files (KNIGHTCODE.md)
You can place a KNIGHTCODE.md file in the root of your project directory. KnightCode automatically scans this file and loads its rules into the agent's system prompt on every session.
- Initialize Guideline: Run
/initto analyze the codebase and generate an initialKNIGHTCODE.mdfile. - Manual Edit: You can write rules (e.g., tech stack details, lint preferences) directly into
KNIGHTCODE.md.
2. Automated Memory Recall & Extraction
KnightCode tracks your feedback, preferences, and workspace facts automatically, storing them as per-project memory files at ~/.knightcode/projects/<encoded-cwd>/memory/.
- Turn-Start Recall: At the start of a turn, a cheap side-query identifies relevant memories from your history and injects them as a
<system-reminder>context block. - Turn-End Extraction: At the end of a completed turn, a serialized background agent (a forked agent) reviews the conversation. It extracts new facts (e.g., "User prefers tabs over spaces for Python files") and saves them as small Markdown note files, updating the
MEMORY.mdindex. - Memory Management: Run
/memoryto open the Memory Manager dialog where you can browse and delete stored memories. - Memory Tool: The agent can call the
Memorytool directly tolist,get,update, ordeletememories. Reads (list/get) run freely;updateanddeleteprompt for your approval unless you're in AUTO mode.