Skip to main content
Extending Qoder CLI

Knowledge Base

Integrate team and project knowledge into Qoder CLI, enabling Agents to leverage existing expertise when completing tasks.

The Knowledge Base refers to the long-term knowledge about your project and team that Qoder CLI can retrieve and reuse when completing tasks. It is not temporary context within a conversation, but rather content that continuously accumulates across sessions and tasks: project conventions, architectural descriptions, module responsibilities, coding standards, and solutions to common issues. With the Knowledge Base, the Agent doesn't need to understand the project from scratch every time. It can:
  • Follow the team's established conventions and standards without requiring you to re-explain them each time.
  • Quickly locate relevant modules and understand module boundaries and dependencies.
  • Reuse past lessons learned and verified solutions to reduce repeated mistakes.
Qoder CLI's knowledge sources primarily consist of three layers: project instructions and rules, long-term memory, and Structured Knowledge Modules. This page explains their differences, how to integrate them, and how to leverage them in daily use.

The Three Layers of Knowledge

Project Instructions and Rules

Project instructions files (AGENTS.md) and rule files describe "how things should be done in this project," such as which package manager to use, directory naming conventions, test commands, and code style preferences. They are committed to the repository along with the project, shared among team members, and automatically loaded by the Agent at the start of a session. This is the most fundamental and commonly used knowledge layer, ideal for project conventions that all contributors should follow. For detailed file locations and loading logic, see Memory.

Long-Term Memory

Long-term memory stores preferences, facts, and habits across sessions, categorized into user-level (applies to all projects) and project-level (applies only to the current project). Unlike project instructions, memory leans more towards "accumulated experiences and preferences" and can be continuously gathered and organized during use. Qoder CLI provides memory management capabilities to maintain this content:
  • The built-in Memory Management Subagent is responsible for adding, deduplicating, and organizing memory entries, routing them to the appropriate storage locations.
  • /remember reviews automatically accumulated memory, suggests promoting entries to project instructions or local instructions files, and identifies outdated, conflicting, and duplicate entries.
For memory hierarchy, routing rules, and management methods, see Memory.

Structured Knowledge Modules

For larger codebases, you can organize subsystem knowledge into Structured Knowledge Modules (e.g., instruction pages split by module), describing the module's architectural design, key files, responsibility boundaries, and usage. This type of knowledge is stored as documentation within the project. The Agent can retrieve it on demand when handling related tasks, rather than cramming all the content into the context at once. Structured Knowledge Modules are ideal for consolidating domain knowledge that "requires significant effort to figure out and will be used repeatedly," enabling both new team members and the Agent to get up to speed quickly.

How to Integrate the Knowledge Base

Establish a Starting Point with /init

Running /init in the project root directory prompts Qoder CLI to analyze the project and generate an initial project instructions file. This is the simplest starting point for integrating the Knowledge Base: start with a basic project instruction and gradually expand it.

Document Project Conventions

Write conventions that all contributors should follow into the project instructions file (AGENTS.md), for example:
# Project Conventions

- Use bun instead of npm to manage dependencies
- Use kebab-case for API route naming
- Run `bun test` before committing
- Prefer functional style

Accumulate and Organize Memory

During daily use, you can have Qoder CLI remember recurring preferences and facts. Subsequently, use /remember to periodically review these auto-memories, promote content worth long-term retention to project instructions or local instructions files, and clean up outdated and duplicate entries.

Consolidate Structured Knowledge

For complex subsystems, organize clearly mapped-out architectures and conventions into Structured Knowledge Modules and commit them to the project. This way, whether it's team members or the Agent later on, they can reuse this knowledge without having to re-explore.

How the Agent Uses the Knowledge Base

When completing tasks, Qoder CLI incorporates the Knowledge Base as part of the background information:
  • Automatic Loading: At the start of a session, project instructions and rules, along with relevant long-term memory, are loaded into the context.
  • On-Demand Retrieval: When facing specific tasks, the Agent retrieves knowledge relevant to the current task (e.g., instructions for a specific module) rather than loading everything at once, saving context space.
  • Acting as Constraints: Retrieved conventions and standards act as behavioral constraints, influencing the Agent's planning and code generation to ensure outputs align with the team's existing practices.
  • Continuous Updates: After task completion, if discrepancies are found between the knowledge and the current state of the code, the corresponding knowledge content can be updated accordingly to maintain the accuracy of the Knowledge Base.

Best Practices

  • Only Write Knowledge That Will Be Reused: The value of the Knowledge Base lies in reuse. Include content that helps subsequent tasks be done better, faster, or more in line with team conventions, rather than one-off temporary information.
  • Keep It Concise and Accurate: Project instructions files are loaded in every session; if they are too long, they will consume context. Move detailed content to Structured Knowledge Modules, keeping only outlines and indexes in the instructions files.
  • Define Clear Layers: Place conventions shared by all contributors in project instructions; put personal preferences in local or user-level memory; and store in-depth knowledge of complex subsystems in Structured Knowledge Modules.
  • Maintain Regularly: As the code evolves, promptly use /remember to organize memory and update instructions files to prevent outdated knowledge from misleading the Agent.
  • Avoid Conflicts and Duplication: Do not repeat the same convention across multiple layers. When conflicts are found, keep the most recent and accurate version.

Next Steps

  • Understand the complete mechanism of memory: Memory.
  • Understand how context works together: Context.
  • Reuse team workflows with Skills: Skills.