Teach AI Your Business Logic by Owning Your Code
An AI coding assistant can produce a convincing function in seconds. Whether that function respects your business rules is another matter. The hard part is rarely getting the syntax right; it is knowing why a customer can cancel one order but not another, which discounts can be combined, and what must happen when a payment provider times out.
Those rules live in code, conversations, tickets, spreadsheets, and the memories of people who have seen the failures. If you want AI to work effectively with your software, make that knowledge visible and keep humans accountable for it. Owning your code means owning the decisions it expresses, including the ones an assistant can easily miss.
Business logic is more than the happy path
Consider a subscription service. A request to “add cancellation” sounds straightforward until the questions arrive. Does access end immediately or at the end of the billing period? What happens to an unpaid invoice? Can a customer reverse the cancellation? Which dates appear in the customer’s time zone?
An assistant can suggest plausible answers, but plausibility is not authority. It may copy a pattern from nearby code, follow an incomplete comment, or implement the most common interpretation of a requirement. Each can produce code that looks polished while quietly changing a commercial promise.
Before asking AI to implement a feature, write down the decisions that govern it. Separate confirmed rules from open questions. If an answer depends on a product owner, legal agreement, or operational process, say so explicitly. An unresolved question is useful context; a fabricated answer is a defect waiting to spread.
Turn decisions into a usable map
AI works better when relevant context is easy to find and small enough to understand. So do new team members and future maintainers. Start with a short explanation of the domain, then link it to the code and examples that enforce the rules.
A useful description of a cancellation rule might identify when access ends, how the effective date is calculated, and which component owns the decision. Include a few concrete cases: a customer cancels before renewal, cancels after a failed payment, or requests cancellation twice. For each case, describe the expected outcome and any important side effects.
Keep the map close to the implementation and give it an owner. Update it when behavior changes, not months later when someone notices a contradiction. Documentation can become stale, so treat it as a guide to verify against current code and agreed requirements, not as an automatic source of truth.
Use tests to make examples executable
Tests are a practical way to preserve decisions that can be checked. A well-named test for “cancelling twice does not create a second refund” tells a future reader more than a comment saying “handle cancellations correctly.” It also gives an assistant a concrete constraint when changing the surrounding code.
Choose examples that cover boundaries and consequences, not just ordinary inputs. For a discount calculation, that could mean an expired promotion, a minimum order value, and a combination of offers that the business prohibits. If rounding matters, specify the currency, the rounding rule, and the point in the calculation where rounding occurs.
Tests still depend on the quality of their expectations. An assistant can generate a test that faithfully confirms an incorrect assumption. Review the expected behavior against the business decision before treating a passing suite as evidence of correctness.
Give the assistant a bounded assignment
A good prompt does not need to contain the entire company handbook. It should identify the goal, the relevant rules, the likely code boundaries, and the checks that matter. For example:
Update the cancellation flow so access continues until the paid-through date. A repeated cancellation request must return the existing effective date and must not issue another refund. Use the existing billing abstraction, add tests for both cases, and flag any behavior that is not specified.
This gives the assistant room to work while making important constraints visible. It also creates a reviewable result: a proposed change, tests, and a list of uncertainties. If the assistant identifies a conflict between the request and existing behavior, resolve the conflict instead of asking it to guess which source wins.
Be deliberate about information boundaries too. Provide the context needed for the task, while following your organization’s rules for sharing customer data, credentials, and proprietary material with the chosen tools. Examples with invented customer details are often sufficient to explain a rule.
Review the consequences, not just the diff
Generated code deserves the same review as any other contribution. Read it with the business process in mind. Ask what happens when a request is repeated, a dependency fails, or two operations arrive close together. Check whether a partial failure can leave one system saying an order is cancelled while another still expects payment.
Retries deserve particular attention. Repeating an operation can be safe for a read and dangerous for a charge or refund. If an external call times out, the caller may not know whether the provider completed it. The design needs a way to reconcile that uncertainty; simply trying again is not a complete failure strategy.
Reviewers should also verify the practical path to release. Does the change require a data migration, a configuration update, or coordination with another service? Can the team observe failures after deployment and respond if the new behavior is wrong? The answers depend on the system, but the questions should not be left to an assistant’s imagination.
Make ownership a habit
Pick one business rule that regularly causes confusion. Find its implementation, write down the agreed behavior and exceptions, and add or improve a few meaningful tests. Then use that context for the next AI-assisted change and compare the proposal with the rule. Repeat as the team encounters other areas of uncertainty.
The aim is not to document every line or prevent assistants from making suggestions. It is to make consequential decisions discoverable, testable, and open to correction. When a team owns those decisions, AI becomes a faster contributor to shared understanding instead of a confident source of unexamined assumptions.