add_learning
The CodePanel MCP tool that records a short fact about a repository for reviewers. An agent's learning stays a candidate until confirmed.
On this page›
add_learning records one short fact about a repository that would stop reviewers repeating a wrong finding, such as "In convex/reviews/, renew() extends the lease before any write". When your agent adds it, it starts as a candidate and applies only once a person, or another identity on another pull request, confirms it. It needs repo and text, and the reviews:write scope.
When to call it
- After a finding was wrong because the reviewers lacked context. The fact should be checkable against the code, not a preference.
- When you have just disputed the same kind of finding twice. A learning is for the next pull request, not this one: it never applies to the pull request it came from.
- Not for a style rule. Rules and notes go through
replace_knowledge. A learning only makes a review look less hard at something, so keep it a factual claim.
Inputs
| Input | Type | Required | Description |
|---|---|---|---|
repo |
string | yes | Repository as owner/name |
text |
string, at most 500 characters | yes | The fact, specific enough to check against code |
scope |
string | no | Path prefix it holds under, e.g. convex/reviews/ |
pr |
integer | no | The pull request this came from. An agent's learning without one can never count toward activation |
agent |
string | no | Your name, e.g. claude-code. Defaults to this MCP client's name |
It writes: the server marks it readOnlyHint: false, so a client that asks before writes asks here.
text is collapsed to one line of single spaces. Over 500 characters is refused, not cut:
CodePanel: A learning is at most 500 characters; this one is 612
scope is a path prefix in the repository: a leading ./ or / is removed, it may not contain spaces or .., and it is at most 200 characters. Without a scope the learning covers the whole repository. A repository holds at most 200 learnings; at the limit the call says to delete some first.
Pass pr with the pull request you are working on. Without it, an agent's learning can never count toward activation, because activation needs ups from two pull requests. The call also records your add as your first up, with that pr.
Why it starts as a candidate
A token call always counts as an agent, whatever agent says, and an agent never confirms its own work. The rule, in order:
- A person's add or up activates it at once. That is the owner on the dashboard or a person's PR comment.
- Two agents can activate it together, if the ups come from different accounts on two different pull requests.
- Any down turns it off at once, from a person or an agent.
- It expires after 180 days without a confirmation of one of those two kinds.
Until then list_learnings shows state.status: "candidate" and state.needs. With one up, needs reads "an up from a person, or an up from another identity on another pull request".
What it returns
ref (L5) and number. The learning isn't applied yet: list_learnings shows its state.
Examples
These responses come from a test account on a local backend.
{
"repo": "codepanel-dev/web-app",
"text": "The login limiter sits behind one load balancer; trust proxy is set to 1 in src/server/app.ts.",
"scope": "src/server/",
"pr": 142,
"agent": "claude-code"
}
{
"number": 5,
"ref": "L5"
}
The new learning, L5, is a candidate on src/server/. It applies to pull requests opened after it activates, not to #142.
The same step without MCP
| Surface | Form |
|---|---|
| Pull request comment | /remember <text> --scope <path> --agent claude-code, one per line (syntax). Bot accounts can't record learnings |
| CLI | codepanel learn <owner/name> <text...> --scope <path prefix> --pr <n> --agent <name> (CLI) |
| HTTP API | POST /learnings |
A /remember comment from a person with write access is that person's up, so it activates the learning at once. The same text through a token does not.
What the server tells your agent
The description your agent reads when it lists the tools:
Record a learning: one short fact about this repository that would stop reviewers from repeating a wrong finding, e.g. "In convex/reviews/, renew() extends the lease before any write". At most 500 characters, one paragraph; give scope as a path prefix when it holds only there. Added by an agent, it is a candidate until a person confirms it or another identity confirms it on another pull request, and it never applies to the pull request it came from. Same as commenting /remember on the pull request. Returns its ref.
Related
rate_learning: confirm someone else's candidate, or turn one off.list_learnings: see states and what each candidate needs.replace_knowledge: the rules and notes, which are edited as a document.- Learnings: activation, drafting and expiry.
- Commands: the
/remembercomment. - MCP server: install, sign-in and every other tool.