Beyond Prompts: Teaching AI Your Business Logic From the Source Code
An AI assistant can describe a function perfectly and still misunderstand the business it serves. It may see a discount calculation, suggest a cleaner formula, and miss the quiet rule that negotiated contracts must never receive that discount. The code compiles. The tests pass. The customer gets the wrong price.
That gap is why better prompts alone are rarely enough. Useful AI assistance depends on giving the model a reliable view of the rules, exceptions, and decisions that make a product work. Source code is a valuable starting point because it shows what the system actually does. But turning that code into usable business context takes judgment, verification, and ownership.
Business logic is scattered across the product
Business logic is the collection of decisions that gives software its commercial meaning: who can approve a refund, when an order becomes final, which customers qualify for a price, or what happens when a payment arrives late. Some rules are explicit in domain classes. Others live in database constraints, background jobs, feature flags, tests, and integrations.
Consider an AI assistant asked to add a refund button. A screen component might reveal how to display it, while an API handler shows how to submit the request. Neither necessarily explains that a refund requires approval after a certain stage, or that an external payment provider can reject it. An assistant working from the visible interface alone can produce a plausible feature that bypasses the process the business relies on.
The first leadership task is therefore to define the boundaries of the question. Which workflow is changing? Where does it start and end? Which systems hold authority over the result? A focused investigation gives both people and AI a better chance of finding the relevant rules than a request to “understand the whole repository.”
Turn implementation into a rule map
Ask the assistant to trace a specific user action through the code and report its findings as a rule map. For each rule, it should identify the evidence, the conditions under which the rule applies, and any uncertainty. A useful map might say that a refund request is accepted only for a completed order, point to the validation that enforces that condition, and note whether there is a separate approval path.
Keep three categories distinct:
- Observed behavior: What the code and tests show the system doing.
- Inferred intent: Why that behavior may exist, which still needs confirmation.
- Open questions: Gaps, conflicting implementations, and cases the available evidence does not resolve.
This distinction prevents a common failure: treating a reasonable explanation as an established requirement. A validation check might exist because of a legal obligation, a temporary operational constraint, or an old defect. The source code can show the check; it may not explain which of those reasons still applies.
Tests are especially useful because they often express examples in business language. They are not a complete specification, though. A passing test proves that the checked behavior held under its setup; it does not prove that every production path, configuration, or integration follows the same rule. Compare the tests with implementation and seek human confirmation where the stakes justify it.
Give the assistant a bounded working brief
Once you have reviewed the rule map, turn it into a compact brief for the task at hand. Include the desired outcome, the rules that must remain true, relevant examples, and the decisions the assistant must not make silently. Point to the source locations that support the brief, so a developer can check them when the code changes.
For the refund feature, the brief could state that the assistant should trace authorization, order status, approval, and payment-provider handling before proposing a change. It could also require the proposal to explain what happens when the provider rejects the refund or when a request is submitted twice. Those are not implementation details to settle by intuition; they affect money, customer trust, and support work.
Give the assistant only the information needed for the work, using the access controls and data-handling practices your organization has chosen. Business context can contain customer data, secrets, or sensitive commercial terms. A useful brief can often describe a rule without exposing the records that led to it.
Review the change as a business decision
AI can help generate a patch and suggest tests, but the team still owns the meaning of the change. Review the result against the rule map, not just against the prompt. Walk through an ordinary case, a boundary case, and a failure case. Ask whether the user sees an accurate status, whether another system can be left out of sync, and whether someone can diagnose a failed operation.
Then verify the behavior with appropriate tests and review. For a refund workflow, meaningful coverage might include an eligible order, an ineligible order, a rejected payment-provider request, and a repeated submission. The exact expected result for each case should come from confirmed product rules, not from whichever behavior is easiest to implement.
When evidence conflicts, stop and resolve the conflict with the people who own the process. A product manager may know the intended customer experience; an operations colleague may understand the exception that keeps a workflow usable; a developer may know why the current implementation behaves differently. Remote teams benefit from recording that decision alongside its rationale, so the next person and the next assistant do not have to reconstruct it from a chat thread.
Keep the knowledge close to the work
A rule map becomes less useful as the product changes. Give important rules an owner, connect them to the relevant code and tests, and update the brief when a change alters the behavior. During review, ask whether the change introduces a new exception or invalidates an existing explanation. Small updates made with the work are easier to sustain than a large documentation effort postponed indefinitely.
The goal is not to make an AI assistant omniscient. It is to give it enough verified context to contribute within a well-understood boundary, and to make uncertainty visible when that context runs out. Source code can reveal what a business has taught its product to do. A thoughtful team turns that evidence into shared knowledge, then keeps responsibility for deciding what the product should do next.