Business Logic
Goal
Define business logic as the rules, algorithms, and workflows in software that govern how data is created, stored, and transformed so real business policies become automated actions.
Treat business logic as purpose-driven code. The key question is not where the code lives, but whether the code expresses a business rule, business decision, business constraint, or business workflow.
What Counts as Business Logic
Classify code as business logic when it does one or more of these things:
- applies a business rule or policy
- makes a business decision from domain data
- calculates a business outcome with domain meaning
- enforces a business constraint or invariant
- changes data according to a business workflow
- controls status or lifecycle transitions with business meaning
- derives values that represent a business concept
- coordinates a sequence of domain actions required by a business process
Business logic often appears in code that answers questions such as:
- whether something is allowed
- how something must be priced, approved, assigned, scheduled, ranked, or settled
- when data can be created, updated, completed, cancelled, renewed, or expired
- which values must be produced from business inputs
Detection Workflow
Read the code for business meaning first.
- Look for domain terms, business concepts, policy names, state names, and vocabulary used by the product, company, or industry.
- Pay attention to rules that would matter even if the implementation language or framework changed.
Identify the business outcome controlled by the code.
- Determine what business decision or business state change the code produces.
- Check whether the code changes how data is created, stored, or transformed in a way that reflects a real policy or workflow.
Trace the rule to inputs, decisions, and outputs.
- Identify the domain inputs the rule depends on.
- Identify the conditions, thresholds, formulas, transitions, and side effects that carry business meaning.
- Identify the resulting domain state, persisted data, or downstream action.
Prefer semantic classification to file or framework conventions.
- Do not assume code is or is not business logic only because of its folder, class name, framework role, or transport boundary.
- Classify by what the code means for the business.
Writing or Changing Business Logic
Preserve the business meaning before refactoring.
- Restate the rule in plain language before changing the code.
- Keep domain terms explicit in names, branches, and data structures.
Make business decisions legible.
- Express thresholds, formulas, eligibility checks, lifecycle transitions, and workflow steps clearly.
- Prefer code shapes that reveal the rule instead of hiding it behind incidental implementation detail.
Keep business rules explicit.
- Avoid scattering one rule across many unrelated edits when a cohesive expression is possible.
- When multiple steps form one workflow, keep the sequence understandable as a single business process.
Protect domain invariants.
- Verify that edited code still enforces the required business constraints.
- Verify that transformed or persisted data still matches the intended business outcome.
Review Questions
When reading or reviewing code, ask:
- What business rule or policy is encoded here?
- What business decision does this branch, formula, or workflow make?
- Which domain inputs drive that decision?
- What business state or business data changes as a result?
- Would a change here alter real business behavior?
If the answer is yes, treat the code as business logic.
Report the Outcome
When finishing the task:
- state which code was identified or treated as business logic
- state which business rules, algorithms, or workflows were implemented or preserved
- state which business inputs, decisions, and outcomes were affected
1---2name: business-logic3description: Identify, interpret, review, or write business logic in code. Use when an agent needs to decide whether code expresses business rules, business algorithms, or business workflows, or when it must implement, preserve, or refactor code that creates, stores, or transforms data according to real business policies.4---56# Business Logic78## Goal910Define business logic as the rules, algorithms, and workflows in software that govern how data is created, stored, and transformed so real business policies become automated actions.1112Treat business logic as purpose-driven code. The key question is not where the code lives, but whether the code expresses a business rule, business decision, business constraint, or business workflow.1314## What Counts as Business Logic1516Classify code as business logic when it does one or more of these things:1718- applies a business rule or policy19- makes a business decision from domain data20- calculates a business outcome with domain meaning21- enforces a business constraint or invariant22- changes data according to a business workflow23- controls status or lifecycle transitions with business meaning24- derives values that represent a business concept25- coordinates a sequence of domain actions required by a business process2627Business logic often appears in code that answers questions such as:2829- whether something is allowed30- how something must be priced, approved, assigned, scheduled, ranked, or settled31- when data can be created, updated, completed, cancelled, renewed, or expired32- which values must be produced from business inputs3334## Detection Workflow35361. Read the code for business meaning first.37 - Look for domain terms, business concepts, policy names, state names, and vocabulary used by the product, company, or industry.38 - Pay attention to rules that would matter even if the implementation language or framework changed.39402. Identify the business outcome controlled by the code.41 - Determine what business decision or business state change the code produces.42 - Check whether the code changes how data is created, stored, or transformed in a way that reflects a real policy or workflow.43443. Trace the rule to inputs, decisions, and outputs.45 - Identify the domain inputs the rule depends on.46 - Identify the conditions, thresholds, formulas, transitions, and side effects that carry business meaning.47 - Identify the resulting domain state, persisted data, or downstream action.48494. Prefer semantic classification to file or framework conventions.50 - Do not assume code is or is not business logic only because of its folder, class name, framework role, or transport boundary.51 - Classify by what the code means for the business.5253## Writing or Changing Business Logic54551. Preserve the business meaning before refactoring.56 - Restate the rule in plain language before changing the code.57 - Keep domain terms explicit in names, branches, and data structures.58592. Make business decisions legible.60 - Express thresholds, formulas, eligibility checks, lifecycle transitions, and workflow steps clearly.61 - Prefer code shapes that reveal the rule instead of hiding it behind incidental implementation detail.62633. Keep business rules explicit.64 - Avoid scattering one rule across many unrelated edits when a cohesive expression is possible.65 - When multiple steps form one workflow, keep the sequence understandable as a single business process.66674. Protect domain invariants.68 - Verify that edited code still enforces the required business constraints.69 - Verify that transformed or persisted data still matches the intended business outcome.7071## Review Questions7273When reading or reviewing code, ask:7475- What business rule or policy is encoded here?76- What business decision does this branch, formula, or workflow make?77- Which domain inputs drive that decision?78- What business state or business data changes as a result?79- Would a change here alter real business behavior?8081If the answer is yes, treat the code as business logic.8283## Report the Outcome8485When finishing the task:8687- state which code was identified or treated as business logic88- state which business rules, algorithms, or workflows were implemented or preserved89- state which business inputs, decisions, and outcomes were affected