Our position: the single source of truth for product development should live in the repository, alongside the code, tests, and instructions that people and AI agents use to change it.
Your agent finishes a feature. In review, an engineer points out a business rule that changes the implementation. The agent corrects it. A week later, another task needs the same explanation because the rule never made it out of the conversation.
The cost lands in review time, repeated prompting, and work that has to be done again. For a CTO or engineering lead, this is where a fast first draft can fail to translate into faster delivery.
We addressed this knowledge gap in Mentingo, our open-source learning platform. Product knowledge had lived across people's heads, Confluence, Google Docs, and the implementation itself. Bringing business specifications into the repository gave the team a shared reference. Making agents update those specifications during development gave that reference a maintenance workflow.
The approach also has limits. An event application showed why product language needs to be explicit. Our internal ICT Project showed why several useful documents still need a clear division of responsibility. In all three cases, engineering has to own the context, the validation, and the decisions behind the code. The second half of the article is a hands-on guide: a complete Mentingo example built from public repository files, step-by-step implementation instructions, a before/after verification test, and a cost model you can fill in with your own numbers.
-
People and AI agents should use the same business specifications, with one maintained source for each product rule.
-
AGENTS.md should guide the agent to the relevant documentation and define when it must be updated.
-
Documentation belongs in the same pull request as a meaningful change to product behavior.
-
Repeated agent mistakes are a reason to inspect missing context, navigation, instructions, and validation.
-
Small teams can establish this workflow early, before undocumented exceptions accumulate.
-
Measure human intervention and review rework to establish the business value. A growing documentation folder is not evidence of a productivity gain.
In our controlled test the specification did not change correctness: the feature was unusually well tested, so the agent could reconstruct the rule from code and tests. What it changed was effort and behavior, with 41% less time to reach the answer and the specification updated in the same change in three of three runs. The questions were written from the specification, which favours the documented variant, so read 41% as an effort signal from three runs per variant, not a benchmark. Expect a correctness difference mainly where the tests do not already state the rule.
What does a single source of truth mean for AI-assisted development?
A single source of truth gives each kind of project knowledge an authoritative home. Business specifications explain product behavior, code defines the implementation, tests provide evidence, and agent instructions explain how to find and use those sources.
The word "single" can be misleading. A repository still needs different documents for different questions. A product owner wants to know who can use a capability. An engineer needs to know where access is enforced. A coding agent may need both answers before it changes a feature.
Problems appear when several documents independently maintain the same rule. A human handbook says one thing, a separate AI guide says another, and an old ticket supplies a third interpretation. The agent can retrieve all three and still have no basis for choosing.
The practical rule is to maintain the fact once and link to it wherever it is needed. An agent instruction can point to the business specification without restating its permissions. An architecture guide can point to an accepted decision without copying its history.
Keeping those sources in the repository makes them versioned and reviewable alongside the implementation. It also makes the relevant context available to an agent working from a checkout, whether the task runs locally or in the cloud.
Confluence, Google Docs, and conversations can still support product discovery. Once a decision governs implementation, it needs a durable destination the team and its agents can find.
How do missing product context and data duplication increase development cost?
Missing context creates work at the point where somebody notices the difference between what was built and what was intended. That work includes explaining the rule, correcting the implementation, updating tests, and reviewing the change again.
Consider a permissions change. The code may correctly implement a new action, while giving it to a role that should never have had access. If review catches the issue, the team pays for another development cycle. If it does not, users can receive behavior the product never intended to offer.
An experienced engineer may remember the restriction from an earlier discussion. An agent starting a fresh task needs evidence available in its working context. Model capability does not make an undocumented business decision available.
This is also why separate documentation for people and agents is expensive. Every duplicated rule has two maintenance paths. A correction made during a conversation with an agent does not automatically update the document a new colleague will read.
Selleo's guide to developer onboarding documentation already highlights the value of shared terminology, test scenarios, and keeping guidance current. AI-assisted development extends that need to every fresh agent session.
Try our developers.
Free for 2 weeks.
No risk. Just results. Get a feel for our process, speed, and quality — work with our developers for a trial sprint and see why global companies choose Selleo.
How did Mentingo build a single source of truth for business processes in its repository?
Mentingo is an open-source learning platform with a React frontend and a NestJS backend. Understanding a feature can require following its UI, permissions, tenant rules, background jobs, integrations, and tests.
Before the documentation workflow, much of the explanation had to be assembled from those implementation sources and knowledge outside the repository. Each source was useful, but incomplete on its own.
A button proves that the interface exposes an action. It does not prove that the server enforces authorization. A backend method proves that an operation exists. It does not prove that a user can reach it. A test establishes the behavior of the scenario it exercises.
The initial documentation change introduced 35 business specifications and a feature-discovery skill. The skill gives the agent a repeatable way to trace product behavior before describing it.
The resulting workflow has three parts: find the relevant context, build an explanation supported by evidence, and update that explanation when the product changes.
Use AGENTS.md to route the agent's data access to the right knowledge
Mentingo's root AGENTS.md covers shared instructions and directs the agent to more specific guidance. The navigation connects these sources:
AGENTS.md
├── apps/api/AGENTS.md
├── apps/web/AGENTS.md
├── docs/specs/
└── .agents/skills/mentingo-feature-overview/SKILL.md
A backend task needs conventions for modules, migrations, permissions, and API tests. A frontend task needs the rules for routes, API clients, and browser tests. Both may need the same business specification.
Loading context as the task needs it is often called progressive disclosure. The root document stays readable, while deeper guidance remains discoverable. It also avoids copying product rules into every agent instruction file.
The business specification is shared knowledge. AGENTS.md explains when and how to use it.
Have the agent trace the feature to keep specification data accurate
The feature-discovery skill directs the agent to inspect how a user reaches the feature, who can access it, what the backend does, which integrations affect it, and what the tests demonstrate. In the Mentingo repository, the skill is called mentingo-feature-overview; the full text is linked in Appendix A.
The specification then explains the product in language a stakeholder can understand, with technical context that lets an engineer check the claims. A simplified template is:
# Feature name
## Business overview
## Who uses it
## Feature functions
## End-user value
## How it works
## Key technical context
## Test evidence
The separation matters. Database structures and service methods may explain an implementation without being capabilities a user can access. The specification needs to preserve that distinction.
Human review of the initial Mentingo specifications caught exactly this kind of problem. Some roles were not clearly supported by the UI evidence, and some explanations presented implementation details as product capabilities. Reviewers corrected the interpretation before accepting the documentation.
Update the documentation in the same task to protect data integrity
Business documentation needs a trigger inside the development workflow. In Mentingo, meaningful changes to product behavior require the matching specification to be updated in the same pull request.
The following is a simplified policy, suitable for adapting to a project's AGENTS.md:
## Documentation during development
- Before changing product behavior, read the relevant business specification.
- If behavior, access rules, or workflow conditions change:
1. Run the feature-discovery workflow.
2. Update or create the relevant document under docs/specs/.
3. Check its claims against the implementation and tests.
4. Include the documentation in the same pull request.
- Flag conflicts between intended and implemented behavior for review.
- Cosmetic or implementation-only changes do not require a business-spec rewrite.
The agent should apply the rule during its work, without waiting for another prompt to update the docs. The reviewer checks the implementation, its tests, and the explanation together.
For example, expanding a role's access changes more than a permission check. It changes the answer to "who can use this feature?" Updating both in the same review makes the new answer available to the next task.
What changed after the Mentingo documentation workflow?
The available evidence supports a change in how knowledge is maintained. We do not yet have measured time or cost savings to report. The end-to-end example below includes two small controlled agent tests; they measure agent behavior and effort on one feature, not team-level savings. In the question test, both the code-only and the documented variant answered every question correctly, so the measured gain is in effort and workflow behavior, not in correctness; read the table below the same way.
The distinction is useful for setting expectations. A repository workflow creates the conditions for less repeated explanation. Measuring whether that happens is the next step.
End-to-end example: one business rule from a single source of truth to verification
Mentingo is open source, so every file in this example is public and can be copied from the Selleo/mentingo repository on GitHub. We use course repetition, added in pull request #2053 (github.com/Selleo/mentingo/pull/2053), because it contains a rule that is easy to misread without context.
Step 1. The problem: a business rule an agent can misread without accurate data
Course repetition lets a learner take a completed course again. The question that matters to HR and L&D teams is what happens to the learner's existing completion and certificate while they repeat it.
The implementation answers that question only after tracing the behavior across course settings, a new API module, certificate issuance, lesson progress, quizzes, SCORM runtime, AI conversations, and reports; pull request #2053 touched 125 files. The existing certificates specification also described administrative resets that clear learner progress, so a reader who stopped there would get the wrong answer.
The accepted rule is different: the learner keeps the accepted completion and certificate until a repetition finishes and a new certificate is issued successfully. This is the rule we document, give to an agent, change, and verify in the steps below.
Step 2. Write the business specification as the single source of truth
The specification was produced with the feature-discovery skill (linked in Appendix A) and reviewed by people before merging. The complete file, as merged, is available in the Mentingo repository: docs/specs/course-repetition-business-spec.md. It is reproduced in full in Appendix B.
Both audiences can use it. The rule is stated in product language under How It Works. The claims an engineer can audit are isolated under Key Technical Context. Test Evidence also says what the tests do not cover.
Step 3. Point AGENTS.md at the specification to avoid data duplication
Mentingo's root AGENTS.md does not restate the repetition rule. It tells the agent where to look and when the specification must change. Two sections of the file do this: Instruction Lookup, which routes backend and frontend tasks to the nested AGENTS.md files, and Definition Of Done.
Here is the fragment, copied verbatim from AGENTS.md at commit b7c3b97:
## Definition Of Done
- Run the narrowest relevant validation command for touched code.
- Update or add tests for changed behavior.
- When a change meaningfully alters a product capability, user workflow, access rule, or business outcome, run `.agents/skills/mentingo-feature-overview/SKILL.md` and update the matching business spec in `docs/specs/<feature-slug>-business-spec.md` as part of the same change. If no spec exists yet, create it. Do not update business specs for cosmetic changes, copy or styling adjustments, implementation-only refactors, or small bug fixes that merely restore already-documented intended behavior.
- Regenerate generated artifacts only through existing scripts.
- Keep changes limited to the task.
- Report commands run, commands skipped, assumptions, and remaining risks.
The third Definition Of Done bullet does the work. It names the trigger (a change to a capability, workflow, access rule, or business outcome), the procedure (the skill), the destination (docs/specs/<feature-slug>-business-spec.md), the timing (the same change), and the exceptions. The exceptions matter as much as the trigger: they stop specifications from churning on refactors and cosmetic changes.
Step 4. Give the agent a task that depends on the rule
Mentingo already sends learners a certificate expiration warning email. We asked an agent to extend it, using the same commit, model, and fresh-session setup as the test in step 6, but with permission to edit files. The agent had no terminal, so it could not run tests or commit. Neither version of the task mentions documentation.
Round 1. The first version of the ticket was underspecified:
Add a link to the certificate expiration warning email that lets learners repeat the course, when the course allows repetition. Follow AGENTS.md.
All three runs read course-repetition-business-spec.md and then stopped before editing to ask a design question. An email link cannot start a repetition, because a repetition is started explicitly, so each agent proposed a link that only highlights the existing Repeat course button. Every plan already included tests and a specification update. For an underspecified ticket, stopping to ask was the right outcome.
Round 2. We put the answer into the ticket:
Add a link to the certificate expiration warning email that lets learners repeat the course, when the course allows repetition. The link should open the course page and highlight the existing Repeat course button; it must not start the repetition by itself. Follow AGENTS.md.
The specification change was written in product language. This is the paragraph the third run added to How It Works:
+When a learner's certificate is close to expiring and the course allows repetition, the warning email adds a note that the course can be repeated and its button reads Repeat course. The button opens the course page and highlights the existing Repeat course button; nothing starts until the learner chooses it. Courses that do not allow repetition keep the original email with an Open course button.
Review still mattered. No run updated certificates-business-spec.md or email-template-builder-business-spec.md, although the round 1 plans had listed the certificates specification. One run reported that existing tenants would not receive the new email variant without a data migration, a product risk that none of the specification updates mentioned. The same run noticed that the current warning email tells learners their course progress will reset after expiry, which contradicts the documented and tested rule. The workflow made these gaps visible; a reviewer still had to decide what to do about them.
If the agent never opens the specifications, treat it as a navigation problem and use the diagnostic checklist later in this article, rather than correcting the agent only in the chat.
Step 5. Change the requirement in one pull request to preserve data integrity
Pull request #2053 is the real example of this step. Course repetition was a new product requirement, and the same pull request carried all three parts of the change:
- Code: a new course-repetition API module, the
repetitionEnabledcourse setting, thePOST /api/course/:courseId/repeatendpoint, and changes to lessons, quizzes, SCORM, certificates, statistics, and reports. - Tests:
apps/api/src/course-repetition/__tests__/course-repetition.e2e-spec.ts(API integration) andapps/web/e2e/specs/learning/course-repetition.spec.ts(Playwright). - Specifications: a new course-repetition-business-spec.md, plus updates to certificates-business-spec.md and lesson-delivery-learning-mode-business-spec.md, so that no older document contradicts the new rule.
Updating the neighboring specifications is the step teams most easily skip. In this case, the change to certificates-business-spec.md separates certificate validity from earned completion and links to the new specification, which removes the misleading reading described in step 1. See the certificates-business-spec.md diff in pull request #2053.
The tests follow the specification closely enough for a reviewer to compare them line by line. Selected test names from the API suite, course-repetition.e2e-spec.ts:
it("requires opt-in and completion")
it("does not allow repeating another learner's state")
it("shows accepted results and repetition progress only within the manager's learner scope")
it("replaces a certificate only after a new qualifying completion")
it("keeps completion and repetition when a certificate expires after opt-out, and honors manual reset")
it("retains the accepted result and certificate when new issuance fails")
Step 6. Verify data accuracy with a fresh agent session
Open a new agent session on the merged branch, with no conversation history, and ask questions whose answers exist only in the documented rule. Do not add your own explanation:
Using only this repository, answer the questions and cite the file for each answer:
1. Can a learner repeat any completed course?
2. What happens to the learner's certificate when they start a repetition?
3. What happens if the certificate expires while a repetition is in progress?
4. Does Mentingo keep a history of previous attempts?
5. Which tests prove the answers to questions 2 and 3?
Expected answers:
- Only courses where a course editor enabled repetition. It is disabled by default, and the learner must be enrolled and have completed the course.
- The certificate remains valid until its deadline or until a new qualifying certificate is issued successfully.
- Expiry archives the certificate but does not reset the accepted completion or the ongoing repetition.
- No. Completing the repetition replaces the previous detailed results; there is no attempt history.
- The certificate tests in course-repetition.e2e-spec.ts listed in step 5.
The test passes when every answer is correct and cites course-repetition-business-spec.md or certificates-business-spec.md. A correct answer reconstructed only from the code is a partial failure: the next agent will have to repeat the same discovery.
We ran this test on Mentingo at commit b7c3b975, the merge of pull request #2053, on 30 October 2026. We used Claude Code 2.1.308 with the claude-sonnet-5-5 model, in fresh non-interactive sessions limited to file reading and search, without network or Git access. In the code-only variant, we deleted docs/specs and changed nothing else. Each variant ran three times.
Every run answered correctly. Mentingo's repetition code is unusually well covered: test names such as "replaces a certificate only after a new qualifying completion" state the rule almost word for word, so an agent could reconstruct it from code and tests. Here, the specification did not change correctness.
It reduced the effort needed to reach the answer, and it changed the answer's form: product language with one citable source, instead of service names, line numbers, and database states.
The runs also surfaced a gap. Three of the six noticed that the expiry test disables repetition before the certificate expires, so no test covers expiry during a repetition on a course that still allows it. The specification's Test Evidence section does not mention this, and it is a candidate for the next update.
Treat these numbers as a single data point: three runs per variant, one model, one well-tested feature, and questions written from the specification. In a codebase with weaker tests, we would expect a larger difference in correctness, but this test does not show that.
Reproduce our tests. Use a fresh clone for every run. We used Claude Code; with another agent, keep the same constraints: the same commit, a fresh session, no network access, read-only tools for the questions, and file editing without a terminal for the task. Save the prompt from this step as questions.txt and the round 2 ticket from step 4 as task.txt, and run each variant three times, because answers vary between sessions. The flags below are those of Claude Code 2.1.308; check them against claude --help in your own version, because flag names change between releases.
git clone https://github.com/Selleo/mentingo mentingo-test && cd mentingo-test
git checkout b7c3b97581bcd4445caf152fb01c4a2a652a8c64
# Step 6, code-only variant: remove the specs (skip this line for the variant with specs)
rm -rf docs/specs
# Step 6: questions about the rule, read-only tools
claude -p "$(cat ../questions.txt)" --model claude-sonnet-5-5
--allowedTools Read Grep Glob --strict-mcp-config --setting-sources project
--no-session-persistence --output-format json > ../questions-run-1.json
# Step 4 (in a fresh clone with specs): implementation task, file editing without a terminal
claude -p "$(cat ../task.txt)" --model claude-sonnet-5-5
--allowedTools Read Grep Glob Edit Write --permission-mode acceptEdits
--strict-mcp-config --setting-sources project
--no-session-persistence --output-format json > ../task-run-1.json
git status --short # code, tests, and docs/specs in the same change? Also lists new files
The JSON output reports the duration, number of agent turns, token usage, and cost that we used in the tables above. For the task, git diff shows whether the business specification changed together with the code and tests.
What can an event application teach us about business processes and context for AI agents?
Product terminology can be enough to create an ambiguity. In an event application we work on, two QR interactions involved opposite actions: an attendee could show a code to an organizer, or scan a code supplied by the organizer.
Similar implementation labels did not make the actor clear. A developer familiar with the product could fill in the meaning, while a new reader could interpret the flow differently.
The team added domain context alongside changes to the check-in implementation and tests. It defined the actors, the methods, which behavior was the default, and which path was used for recovery.
The same repository contains scoped mobile, web, and testing guidance, plus replayable mobile journeys for account creation and event registration. These serve different purposes: explaining the rule, guiding the implementation, and checking a user flow.
This is a useful starting point for teams that do not need a large documentation migration. Make one ambiguous domain explicit, connect it to engineering guidance, and give the next task a way to verify the result. The application remains anonymous because of confidentiality obligations.
Fix the factory instead of fixing the code
When an agent makes a mistake, repair the implementation and investigate the conditions that produced it. A correction kept only in the current chat may have no effect on the next task.
Start by checking whether the missing input was a business rule, an engineering convention, a discovery problem, or a repeatable procedure the agent did not know how to perform.
Put the lesson in the right place:
- Add missing product knowledge to the relevant business specification.
- Add a local engineering convention to the instructions for that part of the repository.
- Encode a repeatable procedure in a skill when it warrants one.
- Improve the navigation if the correct rule already exists but the agent did not find it.
Then repeat the task in a fresh session using the updated repository context. Leave out the extra explanation supplied in the original conversation. This tests whether the improvement is available to future work.
Engineering still has to diagnose the cause. A broken tool, unavailable dependency, or reasoning error will not necessarily be fixed by adding documentation. The goal is to make a correction reusable when the cause supports it.
Why did our ICT Project need data governance policies and clear document ownership?
Our internal ICT Project exposed the risk of having several useful documents without a clear rule for resolving disagreement. An issue could discuss proposed behavior, a specification describe accepted behavior, and a legacy document preserve an older rule.
Review of the documentation modernization work called for an explicit division of responsibility:
- Issues hold discussion, priority, assignment, and delivery status.
- Behavior specifications hold accepted product requirements.
- Project documentation explains architecture, operations, setup, and usage.
- Code and tests show implementation and executable evidence.
- Agent instructions define navigation, workflow, and validation.
An unresolved proposal should not silently replace an accepted requirement. A difference between a specification and the code needs investigation. The easiest file to edit is not necessarily the source that should change.
This is why AI adoption remains specific to each project. Engineers need to define which sources apply and how conflicts are handled. The model can identify a contradiction; the team still owns the decision.
What should you do when documentation is wrong? Protecting data accuracy and data integrity
The workflow reduces the chance that knowledge is lost. It does not make the documentation correct by default. Use this checklist when an agent's output, a review, or a fresh-session test reveals a problem.
The approach is a poor fit, or needs adjusting, in these cases:
- Prototypes whose product rules change daily. A short README is cheaper until the rules stabilize.
- Rules governed outside engineering, such as legal or regulatory requirements. The repository can link to the governing document, but should not become its authoritative copy.
- Teams without code review. The workflow depends on someone checking that the specification matches the intended behavior.
- Large legacy systems documented all at once. Start with the features that generate the most questions and expand from there.
Treat docs/specs and AGENTS.md as part of the agent's working instructions. Review changes to them as carefully as code, because one incorrect line can steer every future task. Keep customer data, credentials, and confidential commercial terms out of specifications, especially in public repositories. If a rule is confidential, keep it in a private repository that the agent accesses with the same permissions as the code.
How do you check whether your repository lacks a single source of truth?
Choose one recently changed feature that usually needs an explanation from an experienced developer. Use it to test whether a new engineer and an agent can reach the same answer from the available sources.
1. Find the documents and implementation that describe the feature
From the repository root, run these ripgrep searches, replacing the placeholders with the feature's actual name, route, or permission:
rg -n "feature name|route name|permission name" .
rg --files | rg 'README|AGENTS|docs|spec|adr|decision|runbook'
Add any external documents or decisions that the team relies on. The search result is an inventory, not proof that the knowledge is complete.
2. Ask the same questions of each source
Who can use the feature? What does the user do? Which configuration changes the behavior? What are the exceptions? Which tests cover those claims?
Record the answer and its source. Different answers reveal a conflict. Missing answers show what still needs to be established.
3. Test whether a fresh reader can find the answer
Give an engineer unfamiliar with the feature and an agent in a fresh session repository access. Ask both to answer the questions and identify their evidence.
If the right document exists but neither reader finds it, improve the links and entry instructions. If they find contradictory sources, establish ownership. If the answer only exists in someone's memory, capture and review it.
4. Put the maintenance rule into the next change
Create or correct the business specification, link it from the relevant instructions, and define when it must be updated. Use the next meaningful behavior change to check whether the agent follows that workflow.
Expand to another domain once the first is working. Add automated checks where the answer is objective, such as broken links, missing sections, or generated contracts that differ from their inputs. Keep disputed product intent in human review.
Implement it yourself: build a single source of truth in your repository
The steps below turn the Mentingo workflow into a setup you can reproduce in your own repository. Start with the feature you chose in the previous section.
Prerequisites
- A Git repository with pull request review.
- A coding agent that reads repository instruction files such as AGENTS.md. In our tests, Claude Code 2.1.308 loaded the root AGENTS.md automatically, although Mentingo has no CLAUDE.md: with every tool disabled, the agent still quoted the file's instructions verbatim. If your agent does not read AGENTS.md, import it into the file the agent does read instead of copying its content. For Claude Code, that is a CLAUDE.md containing the single line
@AGENTS.md. - ripgrep (
rg) or another code search the agent can run. - An automated test suite that covers at least part of the chosen feature.
- An engineer who owns the workflow and a product owner who can confirm business rules.
Step 1. Create the structure
mkdir -p docs/specs .agents/skills/feature-discovery
touch AGENTS.md
Mentingo keeps skills in .agents/skills/. If your agent loads skills from another directory (Claude Code uses .claude/skills/), put the skill there. An agent without skill support can still follow it, because the AGENTS.md rule in step 3 names the file path directly.
Step 2. Add the feature-discovery skill
Download the original skill, also linked in Appendix A, into .agents/skills/feature-discovery/SKILL.md:
curl -fsSL https://raw.githubusercontent.com/Selleo/mentingo/b7c3b97581bcd4445caf152fb01c4a2a652a8c64/.agents/skills/mentingo-feature-overview/SKILL.md
-o .agents/skills/feature-discovery/SKILL.md
Then adapt three parts and leave the rest unchanged for the first iteration:
- Front matter: change name to feature-discovery and describe your product in description.
- Discovery Workflow: replace the apps/web, apps/api, and packages/shared paths with your frontend, backend, test, and shared-contract locations.
- Business Lens: replace HR and L&D with your product's users and the jobs they need to finish.
If you prefer to start from a smaller, product-neutral version, use this skeleton and fill in the placeholders in angle brackets:
---
name: feature-discovery
description: Trace how a product feature works from code, tests, routes, and permissions, then write or update its business spec in docs/specs. Use when a change alters a product capability, user workflow, access rule, or business outcome.
---
# Feature Discovery
## Discovery Workflow
1. Read the root AGENTS.md and the AGENTS.md for each area the feature touches.
2. Find the feature surface with rg and rg --files: product wording, routes, permission names, test titles, visible labels.
3. Map the frontend: <routes>, <UI modules>, <route access config>, <translations>.
4. Map the backend: <controllers/handlers>, <services>, <permissions/policies>, <jobs/events>.
5. Map the tests: <frontend E2E>, <backend integration tests>.
6. Map shared contracts: <shared constants, permissions, types>.
## Source Discipline
- Tie every business claim to UI, API, permission, or test evidence.
- Label claims inferred from implementation only.
- Name a role only when UI, access rules, permissions, or tests show it can use the feature.
- Only edit files under docs/specs.
## Business Lens
- Who uses it: <your product's roles>.
- What concrete job they are trying to finish: <jobs, not features>.
- What value it creates: <outcomes>.
Translate implementation nouns into product nouns:
- Say "learners receive the announcement in their feed",
not "user_announcements records are created".
- Say "HR can target a specific group",
not "the service filters by groupId".
## Business Spec Format
Save to docs/specs/<feature-slug>-business-spec.md with these sections:
- Business Overview: what it enables, for whom, the main workflow.
- Who Uses It: persona + scenario + outcome.
- Feature Functions: 4-8 verb-first user capabilities, most valuable first.
- End-User Value: benefits only.
- How It Works: the user workflow first, then rules, defaults, and exceptions.
- Key Technical Context: 3-6 facts an engineer can audit.
- Test Evidence: what the tests prove and what they do not cover.
## Quality Bar
- A stakeholder can read it; an engineer can audit it.
- Database tables, service methods, and endpoints are never presented as user capabilities.
- Reread before finishing; remove unsupported roles and duplicate bullets.
Step 3. Add the documentation rule to AGENTS.md
A minimal AGENTS.md, based on Mentingo's. Replace the placeholders in angle brackets:
# AGENTS.md
## Instruction Lookup
- Start with this file.
- Before changing product behavior, read the matching business spec in `docs/specs/`. List them with `rg --files docs/specs`.
- Backend changes: also read `<backend-dir>/AGENTS.md`. Frontend changes: also read `<frontend-dir>/AGENTS.md`.
## Commands
- Tests: `<your test command>`
- Lint/typecheck: `<your lint command>`
## Definition Of Done
- Run the narrowest relevant validation command for touched code.
- Update or add tests for changed behavior.
- When a change meaningfully alters a product capability, user workflow, access rule, or business outcome, run `.agents/skills/feature-discovery/SKILL.md` and update the matching business spec in `docs/specs/<feature-slug>-business-spec.md` as part of the same change. If no spec exists yet, create it. Do not update business specs for cosmetic changes, copy or styling adjustments, implementation-only refactors, or small bug fixes that merely restore already-documented intended behavior.
- If a business spec and the implementation disagree, do not silently change either one. Report the conflict.
- Report commands run, assumptions, and which business spec you updated or why no update was needed.
Step 4. Generate the first specification
Run this prompt in your agent:
Use .agents/skills/feature-discovery/SKILL.md to document the <feature name> feature.
Save it to docs/specs/<feature-slug>-business-spec.md.
For every business rule, cite the UI, API, permission, or test evidence.
Mark anything inferred from implementation only.
Do not change any other file.
Expected result: one Markdown file with the sections from the template, comparable to the course repetition specification linked in the end-to-end example, opened as a pull request.
Step 5. Review the specification as a product decision
An engineer and the product owner review the pull request, just as they would review code. Check that every role is supported by evidence, that implementation details are not presented as user capabilities, that exceptions and defaults known only to people are added, and that claims without test coverage are marked as inferences. In Mentingo, this is the stage where reviewers corrected unsupported roles. Merge only when both reviewers accept the content.
Step 6. Use the next behavior change as the real test
Give the agent the next ticket that changes the documented feature, without mentioning documentation in the prompt. Expected result: a single pull request with code, tests, and the updated specification, and a description that names the specification. If the specification is missing, fix the wording of the rule in AGENTS.md instead of reminding the agent in the chat.
Make the rule visible to reviewers with a pull request template. GitHub reads it from .github/pull_request_template.md. The last two fields also collect the data for the business impact measurement described later:
## Business spec
- [ ] Updated: `docs/specs/<feature-slug>-business-spec.md`
- [ ] Not needed, because: <cosmetic / refactor / bug fix restoring documented behavior>
- [ ] No other document still states the old rule (`rg -n "<old phrase>" docs AGENTS.md`)
## Agent context
- Time spent explaining context to the agent (minutes): __
- Agent retries before this version: __
Step 7. Verify, automate the objective checks, and expand
Run the before/after test from the next section. Then add automated checks where the answer is objective. Save this script as scripts/check-specs.sh. It fails when a specification is missing a required section. The heading match ignores case, so both the sentence-case template above and Title Case headings pass, and an empty docs/specs/ directory does not cause an error:
#!/usr/bin/env bash
# scripts/check-specs.sh
set -euo pipefail
shopt -s nullglob
missing=0
for f in docs/specs/*-business-spec.md; do
for h in "Business Overview" "Who Uses It" "Feature Functions" "End-User Value" "How It Works" "Key Technical Context" "Test Evidence"; do
grep -qi "^## $h" "$f" || { echo "$f: missing ## $h"; missing=1; }
done
done
exit $missing
We ran it on Mentingo at commit b7c3b975: 53 of the 57 specifications passed. The other four use a different set of sections; for example, the AI conversations specification has no Key Technical Context or Test Evidence section. Before you make the check required, decide whether such variations are allowed, and then change either the specifications or the list in the script.
To run the check on every pull request on GitHub, add this workflow:
# .github/workflows/specs-check.yml
name: Business specs
on: pull_request # no paths filter: the check must report a status on every PR
jobs:
check-specs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # needed to diff against the base branch
- name: Required sections in every spec
run: bash scripts/check-specs.sh
- name: Warn when code changes without a spec update
run: |
changed=$(git diff --name-only "${{ github.event.pull_request.base.sha }}"...HEAD)
if grep -qE '^(apps|src)/' <<<"$changed" && ! grep -q '^docs/specs/' <<<"$changed"; then
echo "::warning::Code changed without a business-spec update. Confirm the 'Not needed, because' box in the PR template."
fi
A paths filter looks like a cheap optimization and is a trap here. The workflow would run only on pull requests that already touch docs/specs/, so it would never see the case the rule exists for — code changed without a specification update. Worse, a required status check with a paths filter never reports on pull requests outside those paths, and GitHub keeps such a pull request permanently pending rather than treating it as skipped. The script takes seconds, so run it on every pull request. Keep the code-without-spec step as a warning: CI cannot tell a meaningful behavior change from a refactor, and a blocking check would only teach people to touch a spec file to get a green build.
When the first feature passes, document the next feature that generates the most questions.
After the seven steps, you should have:
- A reviewed business specification for each documented feature in docs/specs/.
- An AGENTS.md rule that the agent follows without reminders.
- At least one merged pull request with code, tests, and specification together.
- A passing fresh-session test for each documented feature.
How do you verify that your single source of truth works?
Run the same test twice: before you add the specification, and after the first behavior change that follows it. Use a fresh agent session each time, the same model and tool versions, and no explanation beyond the task itself.
The before/after test
- Find: ask "Where is the rule for <business rule> defined? Cite the file." Before, the agent can only point to code, if it finds the rule at all. After, it cites the specification.
- Apply: give a small task that depends on the rule, like step 4 of the Mentingo example. Before, the result is correct only if the code makes the rule obvious. After, the implementation and tests follow the rule on the first review.
- Update: give a task that changes the rule. After, one pull request updates the code, tests, and specification, and no other document still states the old rule.
For each run, record whether the result was correct, the number of human corrections, the number of agent retries, and the reviewer's time in minutes. These are the same measures used in the business impact section below.
Pass criteria
- The agent opens the relevant specification without being given its path.
- Every answer cites a repository file, and that file states the rule.
- Review comments on the implementation concern code quality, not a misunderstood business rule.
- The rule-changing pull request contains code, tests, and specification together.
- After that pull request,
rg -n "<phrase from the old rule>" docs AGENTS.mdfinds no document stating the old rule. - A second fresh session gives the same answers to the same questions.
- An engineer unfamiliar with the feature reaches the same answers from the same files.
If a criterion fails, use the diagnostic checklist above to decide whether the problem lies in the content, the navigation, or the instruction.
Should small teams build a single source of truth from the start?
Yes. A small team has less capacity to repeat explanations, and a new project has fewer legacy sources to reconcile. Establishing repository documentation early makes it easier to keep implementation and product knowledge together as the codebase grows.
Start with a short entry document, specifications for the important user flows, and a documentation update rule in AGENTS.md. Add scoped instructions and skills as real work exposes a need.
If your ambition is to have agents generate most or all of an implementation, the quality of the context and validation becomes more important. Generated-code percentage alone does not show how much human work was needed to reach an acceptable result.
The structure can stay small. The maintenance habit should start immediately.
How do you measure the impact of agent context on business performance?
Measure the work needed to get a change accepted. A faster first response is useful, but it does not include the cost of explanation, correction, and review.
For a group of comparable tasks, record:
- Human time spent explaining missing product knowledge.
- Review corrections caused by misunderstood roles, rules, or workflows.
- Agent retries required before acceptance.
- Time spent maintaining and reviewing the documentation itself.
Compare the results before and after improving the relevant context. Account for task complexity and changes in the model or tooling. Otherwise, a model upgrade can be mistaken for a documentation improvement.
A basic financial calculation is the value of engineering time saved, less the cost of maintaining the knowledge. Use the team's measured hours and internal cost assumptions. The Mentingo, event-application, and ICT Project examples do not establish a universal savings figure.
For planning and launch decisions, those measurements need to remain separate from product adoption or revenue. Selleo's product launch checklist makes a similar distinction between engineering evidence and commercial outcomes.
A worked example: hypothetical scenario
Hypothetical illustrative scenario. The figures below are assumptions, not measured Mentingo results. Replace them with your team's numbers.
The formulas, using the figures above:
Annual benefit = hours recovered per week × hourly cost × working weeks
= 6 × 200 × 48 = PLN 57,600
First-year ROI = (annual benefit − first-year cost) / first-year cost
= (57,600 − 14,400) / 14,400 = 300%
Payback period = implementation cost / (weekly benefit − weekly maintenance)
= 4,800 / (1,200 − 200) ≈ 5 weeks
6 h × PLN 200 × 48 working weeks
PLN 4,800 implementation + PLN 9,600 maintenance
(57,600 − 14,400) / 14,400
4,800 / (1,200 − 200)
Treat the six hours as the hypothesis to test, not the result. If measurement after a quarter shows only two hours recovered per week, the annual benefit is PLN 19,200, still above the first-year cost of PLN 14,400. Add agent usage costs if running the skill on every behavior change is material for your setup.
Agent cost does not drive the result. In our tests, answering the rule questions cost USD 0.17 with specifications and USD 0.27 without them, and implementing the change in step 4 cost USD 1.19 on average, a small fraction of one engineering hour. The measured gains are in agent time and in behavior: 41% less time to find the rule, and the specification updated in the same change in three of three runs. The variable that decides the ROI is engineering time, which we have not yet measured in Mentingo. The measures below are how to collect it.
Collecting the data does not require new tooling:
- Label review comments that correct a misunderstood business rule and count them per sprint.
- Add one field to the pull request template: time spent explaining context to the agent, in minutes.
- Record agent retries before acceptance and the fresh-session test result for each documented feature.
- Log the time spent updating and reviewing specifications, so the maintenance cost is measured too.
Some value stays outside the formula: a lower risk of shipping incorrect access rules, faster onboarding for engineers who read the same specifications, and less dependence on the one person who remembers how a feature should behave.
How can Selleo help build a single source of truth?
Selleo can help assess how project knowledge reaches the people and agents doing the work. A useful starting point is a feature that repeatedly creates questions or review corrections.
We can trace its documentation, code, and tests, identify missing context or competing sources, and prioritize changes by their likely effect on development effort and risk. The result may be a business specification, clearer agent instructions, a repository skill, or a validation step.
Engineering ownership stays with the team. An agent can discover evidence and prepare updates, while people remain responsible for product intent, documentation quality, and the decision to ship.
Talk to Selleo about your development workflow. Bring one feature your team keeps explaining, and use it to establish what the next task should already know.
For product rules that govern implementation, we recommend an authoritative version in the repository. Confluence can support collaboration and research, provided accepted decisions are captured and linked to the development workflow. A rendered documentation site can also make repository content accessible to people who do not work in Git.
It is the entry point for instructions and navigation. Business rules, architectural decisions, and executable contracts should remain in their own authoritative sources. Link to them instead of duplicating their contents in AGENTS.md.
An agent can update specifications during implementation when its instructions define the trigger, destination, and validation. The team must check that it follows the rule and review whether the explanation matches accepted product behavior. Instructions support the workflow; they do not guarantee compliance.
A more capable model may interpret evidence more effectively, but it still needs access to project decisions. Business rules held only in people's heads remain missing inputs. Better context and better models address different parts of the problem.
Appendix A: where to get the feature-discovery skill
The complete SKILL.md, in the version used for the test in the end-to-end example, is available in the Mentingo repository: mentingo-feature-overview/SKILL.md. Before using it in another product, adapt the paths and the Business Lens section as described in step 2 of "Implement it yourself".
Appendix B: the course repetition business specification (as merged)
The complete file from the Mentingo repository at commit b7c3b975, reproduced verbatim. It is the specification the agent reads in the end-to-end example. Note how the product rule is stated in plain language under How It Works, the auditable facts are isolated under Key Technical Context, and Test Evidence states what the tests do not cover.
Business Overview
Learners can repeat an opted-in course to renew their training while retaining their accepted completion until they finish. Course managers enable repetition in the existing course settings.
Mentingo keeps the accepted course result and one temporary repetition. During repetition, the learner starts with fresh lesson progress and results. Completing it replaces the accepted result. Previous detailed results are removed; this feature does not provide an attempt history.
Who Uses It
- Learners repeat completed training and resume an unfinished repetition on their next visit.
- Course editors enable repetition for training that learners may need to renew.
- Administrators and group managers check accepted completion alongside ongoing repetition, within their existing course and learner access.
Feature Functions
- Start a repetition explicitly after completing a course.
- Resume the same repetition after leaving or refreshing the page.
- Show accepted completion and ongoing repetition progress separately.
- Start quizzes, video coverage, SCORM runtime and course AI conversations with fresh learning state.
- Replace the accepted detailed results when repetition completes.
- Replace an active certificate only after a new qualifying certificate is issued successfully.
- Preserve accepted completion and ongoing repetition when a certificate expires.
- Let course editors disable further repetitions while allowing an existing repetition to finish.
End-User Value
Learners can renew training without temporarily losing proof that they already completed it. Managers can distinguish an accepted outcome from training currently being repeated. Existing reports continue to count each trained learner once, and learning time retains the actual time invested across repetitions.
How It Works
The learner opens an enrolled, completed course and chooses Repeat course. Mentingo starts fresh progress and opens the first lesson. Returning to the course continues that repetition. Ordinary review of completed materials remains a separate existing action.
While repetition is underway, the course shows the accepted completion and repetition progress. Authorized manager details retain accepted results and additionally show how much of the repetition is complete. Reviewing another learner's accepted lesson results does not advance that learner's progress.
When the learner satisfies the existing completion rules, the repeated result becomes current and the temporary repetition disappears. The former detailed lesson and runtime results are removed. There is no list or numbering of earlier attempts.
A prior certificate remains valid until its existing deadline or successful replacement. If the course issues certificates, a new qualifying completion produces the replacement and archives the prior active certificate. A failed issuance leaves the previous accepted result and certificate intact. Certificate expiry affects validity only and does not reset learning, including when validity is shortened. Earned completion remains earned independently of repetition availability or whether the learner has ever repeated; an unfinished course remains unfinished. An explicit administrative certificate reset retains its reset effect and removes the temporary repetition.
Repetition is disabled by default and requires existing course-edit permissions to enable. Starting it requires learner access, enrollment and prior completion. Existing content changes, lesson removal, sequencing and resume rules continue to apply; repetition does not introduce frozen course-content versions.
Key Technical Context
- The existing course setting is
repetitionEnabled; learners start repetition throughPOST /api/course/:courseId/repeat. - One enrollment remains authoritative. Learning state is limited to current and temporary repetition, with tenant isolation and existing group-manager boundaries.
- Learning writes carry a state identity. Duplicate start requests resolve the same repetition, and obsolete writes cannot update another state.
- Completion replacement and certificate issuance use transactions; durable completion notifications reuse the existing outbox.
- Aggregate learning time is retained independently of detailed state replacement, including time spent in an older browser tab after another tab starts repetition. The capability has no plugin dependency.
Test Evidence
- API integration tests cover eligibility, parallel starts, fresh runtime state, resume, state replacement, stale writes, opt-out, certificates and administrative reset. They exercise real persistence without calling AI providers.
- Frontend component tests cover the explicit action, active repetition after opt-out and failed starts.
- Playwright covers enabling the setting, initial completion, repetition, resume after refresh and replacement through the learner interface.
- These tests do not verify a live AI provider conversation or every third-party SCORM package.