# AI Patterns > Design patterns, refactoring techniques and code smells, written for AI coding agents. Every page is available as Markdown at `.md`, through the MCP server, and as installable skills. - MCP endpoint (Streamable HTTP, OAuth): https://aipatterns.dev/mcp - clients open a sign-in on first connect - Skills: `npx skills add https://aipatterns.dev` - Full text for LLMs: https://aipatterns.dev/llms-full.txt ## Sections - [Design patterns](https://aipatterns.dev/design-patterns.md): the 22 classic patterns plus original categories - resilience (timeout, circuit breaker, retry, exponential backoff, fallback, rate limiting), data (cache-aside, transactional outbox, saga, idempotent consumer, cqrs) and architecture (strangler fig, backends for frontends) - each with "do not use it when" guidance. - [Refactoring techniques](https://aipatterns.dev/refactoring/techniques.md): small, behavior-preserving transformations. - [Code smells](https://aipatterns.dev/refactoring/smells.md): symptoms, and which technique treats each one. - [Guides](https://aipatterns.dev/guides.md): concepts, and how to choose a pattern. - [For agents](https://aipatterns.dev/agents.md): MCP setup and usage rules. - [Skills](https://aipatterns.dev/skills.md): installable skill packs. - [Benchmark](https://aipatterns.dev/benchmark.md): agents with and without the MCP server, and the method. ## Entries - [What Is a Design Pattern](https://aipatterns.dev/guides/what-is-a-pattern.md): A design pattern is a named, reusable solution shape for a recurring design problem. Learn what one contains and how it differs from an algorithm or library. - [History of Patterns](https://aipatterns.dev/guides/history-of-patterns.md): Where design patterns came from, from Christopher Alexander's architecture books to the Gang of Four catalog, and what changed in how they are used today. - [Why Learn Patterns](https://aipatterns.dev/guides/why-learn-patterns.md): What knowing design patterns buys a developer or coding agent: shared vocabulary, faster code reading, better refactoring targets, and knowing when to stop. - [Criticism of Patterns](https://aipatterns.dev/guides/criticism-of-patterns.md): The main arguments against design patterns, including missing language features, misuse, and over-engineering, and how to apply patterns without those failures. - [Classification of Patterns](https://aipatterns.dev/guides/classification-of-patterns.md): How the 22 classic design patterns are grouped by purpose into creational, structural and behavioral, plus other useful ways to slice them. - [Factory Comparison](https://aipatterns.dev/guides/factory-comparison.md): Tell apart a factory function, static creation method, simple factory, Factory Method and Abstract Factory, and pick the smallest one that fits. - [Visitor and Double Dispatch](https://aipatterns.dev/guides/visitor-and-double-dispatch.md): Why overloading alone cannot pick a method by an argument's runtime type, how Visitor uses double dispatch to fix it, and when pattern matching replaces it. - [Choosing a Pattern](https://aipatterns.dev/guides/choosing-a-pattern.md): A decision guide that maps concrete code symptoms to the pattern that fixes them, and tells you when plain code beats any pattern. - [Eval-Driven Development](https://aipatterns.dev/guides/eval-driven-development.md): Write the task-and-verifier pairs before the tool, prompt or agent, then let the numbers decide changes - the same discipline as tests-first, applied to components whose output is text. - [How Agents Should Use This Reference](https://aipatterns.dev/guides/for-agents.md): Rules for AI coding agents using this reference: diagnose a named smell, read the exclusions first, apply one technique at a time and verify with tests. - [What Is Refactoring](https://aipatterns.dev/guides/what-is-refactoring.md): Refactoring changes the internal structure of code in small, behavior-preserving steps so it becomes cheaper to read and change. - [Technical Debt](https://aipatterns.dev/guides/technical-debt.md): Technical debt is the extra cost every future change pays because of shortcuts and drift in today's code. Learn its causes and how to pay it down. - [When to Refactor](https://aipatterns.dev/guides/when-to-refactor.md): Refactor right before you change code, while fixing a bug and during review. Skip it when the code is due for deletion or has no tests. - [How to Refactor](https://aipatterns.dev/guides/how-to-refactor.md): Refactor in small named steps, run tests after each one, never mix in behavior changes, and stop when the code is clean enough for the task at hand. - [Creational Patterns](https://aipatterns.dev/design-patterns/creational.md): Patterns that control how objects get built, so callers depend on what they need rather than on which concrete class supplies it. - [Structural Patterns](https://aipatterns.dev/design-patterns/structural.md): Patterns that combine objects and classes into larger structures while keeping each part replaceable and its interface small. - [Behavioral Patterns](https://aipatterns.dev/design-patterns/behavioral.md): Patterns that assign responsibilities and route requests between objects, so behavior can change without rewriting the code that triggers it. - [Resilience Patterns](https://aipatterns.dev/design-patterns/resilience.md): Patterns for calls that can fail, hang or come back wrong: bound the wait, count the failures, space the repeats, and continue with a lesser answer. - [Data Patterns](https://aipatterns.dev/design-patterns/data.md): Patterns for keeping application data honest at speed and across services: copies that exist only to be lost, multi-step transactions with explicit undos, and messages that cannot be lost or doubled. - [Architecture Patterns](https://aipatterns.dev/design-patterns/architecture.md): Patterns for system boundaries and change over time: replace without stopping, and give each client a backend shaped for it - decisions measured in routes and releases, not classes. - [Bloaters](https://aipatterns.dev/refactoring/smells/bloaters.md): Smells where methods, classes and parameter lists grow too large to read, test or change safely, usually one small addition at a time. - [Composing Methods](https://aipatterns.dev/refactoring/techniques/composing-methods.md): Techniques that split, merge and reshape method bodies so each method does one readable thing and local variables stop blocking change. - [Moving Features between Objects](https://aipatterns.dev/refactoring/techniques/moving-features-between-objects.md): Techniques that relocate methods, fields and whole classes so each responsibility lives next to the data it uses. - [Object-Orientation Abusers](https://aipatterns.dev/refactoring/smells/oo-abusers.md): Smells where object-oriented features are missing or misapplied, such as type switches, half-used fields and inheritance that does not fit. - [Change Preventers](https://aipatterns.dev/refactoring/smells/change-preventers.md): Smells where one change forces edits in many places, or one class changes for many unrelated reasons, making every edit slow and risky. - [Organizing Data](https://aipatterns.dev/refactoring/techniques/organizing-data.md): Techniques that turn raw fields, magic values, arrays and type codes into objects and types that carry meaning and protect their own invariants. - [Dispensables](https://aipatterns.dev/refactoring/smells/dispensables.md): Smells where code, comments or abstractions add nothing, and removing them makes the program shorter and clearer with no loss of behavior. - [Simplifying Conditional Expressions](https://aipatterns.dev/refactoring/techniques/simplifying-conditional-expressions.md): Techniques that flatten, name, merge and replace conditionals so branching logic reads as a list of plain decisions. - [Couplers](https://aipatterns.dev/refactoring/smells/couplers.md): Smells where classes depend too much on each other's data or structure, or where delegation is overused, so one change ripples through others. - [Simplifying Method Calls](https://aipatterns.dev/refactoring/techniques/simplifying-method-calls.md): Techniques that clean up method signatures, names, parameters and error signaling so interfaces are hard to call incorrectly. - [Dealing with Generalization](https://aipatterns.dev/refactoring/techniques/dealing-with-generalization.md): Techniques that move members up and down class hierarchies, create or collapse hierarchies, and swap inheritance for delegation. - [Other Smells](https://aipatterns.dev/refactoring/smells/other.md): Smells that do not fit the main groups, currently the gap left when a library class you cannot edit lacks an operation you need. - [Strangler Fig](https://aipatterns.dev/design-patterns/strangler-fig.md): Put an interception layer in front of a legacy system and move routes to the replacement one at a time, until the old system has nothing left to serve and can be removed. - [Backends for Frontends](https://aipatterns.dev/design-patterns/backends-for-frontends.md): Give each frontend its own backend that aggregates and shapes the services it needs - so the web app, the mobile app, and any other client stop negotiating one API into serving them all. - [Chain of Responsibility](https://aipatterns.dev/design-patterns/chain-of-responsibility.md): Pass a request along a chain of handlers until one decides it, so the sender never knows which handler acts or how many exist. - [Command](https://aipatterns.dev/design-patterns/command.md): Wrap an action and its arguments in an object so you can queue, log, retry or undo it separately from the code that triggers it. - [Iterator](https://aipatterns.dev/design-patterns/iterator.md): Walk the elements of a collection one at a time through a standard interface, without exposing how the collection stores or fetches them. - [Mediator](https://aipatterns.dev/design-patterns/mediator.md): Route interactions between a group of components through one coordinator so they stop referencing each other and the rules live in one place. - [Memento](https://aipatterns.dev/design-patterns/memento.md): Capture an object's internal state in an opaque snapshot so it can be restored later without exposing that state to the code holding the snapshot. - [Observer](https://aipatterns.dev/design-patterns/observer.md): Let an object announce its changes to a list of subscribers it does not know, so new reactions plug in without editing the source of the change. - [State](https://aipatterns.dev/design-patterns/state.md): Move each mode of an object into its own class so behavior and transitions change with the mode instead of branching on a status field. - [Strategy](https://aipatterns.dev/design-patterns/strategy.md): Put each interchangeable algorithm behind one interface so the caller picks a behavior at runtime without branching on it. - [Template Method](https://aipatterns.dev/design-patterns/template-method.md): Fix an algorithm's sequence of steps in a base class and let subclasses fill in or override individual steps without changing the order. - [Visitor](https://aipatterns.dev/design-patterns/visitor.md): Add new operations over a fixed set of node types without editing those types, by routing each node to a type-specific method on a visitor object. - [Factory Method](https://aipatterns.dev/design-patterns/factory-method.md): Let a subclass or a supplied function decide which concrete object to create, so shared workflow code depends only on an interface. - [Abstract Factory](https://aipatterns.dev/design-patterns/abstract-factory.md): Create families of related objects through one interface so client code always gets a matching set and never names the concrete classes. - [Builder](https://aipatterns.dev/design-patterns/builder.md): Assemble a complex object through named, step-by-step calls and validate it once in build(), instead of a constructor with many parameters. - [Prototype](https://aipatterns.dev/design-patterns/prototype.md): Create new objects by copying a configured existing instance, so callers get a ready-made variant without knowing its class or setup. - [Singleton](https://aipatterns.dev/design-patterns/singleton.md): Guarantee one instance of a class per process with a global access point. Usually better replaced by one instance created at startup and injected. - [Cache-Aside](https://aipatterns.dev/design-patterns/cache-aside.md): Read through a cache: on a miss, load from the store and fill it; on a write, save to the store and evict the entry - so reads speed up while the store stays the only source of truth. - [Transactional Outbox](https://aipatterns.dev/design-patterns/transactional-outbox.md): Write the outgoing message in the same transaction as the business change; a relay publishes and marks it sent - the commit and the message become one fact, not two hopes. - [Saga](https://aipatterns.dev/design-patterns/saga.md): Run a multi-step transaction as local steps, each with a compensation; on failure, compensate the completed steps in reverse - consistency by explicit undo, not locks. - [Idempotent Consumer](https://aipatterns.dev/design-patterns/idempotent-consumer.md): Record the ids of processed messages and skip ids already seen, so a redelivered webhook or queue event processes once no matter how many times it arrives. - [CQRS](https://aipatterns.dev/design-patterns/cqrs.md): Split the command model from per-view query models, joined by projections - each side shaped for its job, at the price of two models and eventual consistency. - [Timeout](https://aipatterns.dev/design-patterns/timeout.md): Give every remote call a deadline shorter than the caller's own budget, cancel the work when it expires, and surface the timeout as a distinct error. - [Circuit Breaker](https://aipatterns.dev/design-patterns/circuit-breaker.md): Count consecutive failures to a dependency, refuse calls while it looks broken, and let one probe test recovery - so a dead service cannot eat its callers. - [Retry](https://aipatterns.dev/design-patterns/retry.md): Re-attempt only retryable, repeatable operations a bounded number of times, honour Retry-After, check cancellation between attempts, and surface the last error. - [Exponential Backoff](https://aipatterns.dev/design-patterns/exponential-backoff.md): Space repeat attempts at base times two raised to the attempt, capped, with random jitter - so retries spread out instead of arriving in a synchronized herd. - [Fallback](https://aipatterns.dev/design-patterns/fallback.md): Return a pre-decided lesser answer when a dependency cannot - stale cache, static default, partial result - so the journey continues, marked as degraded. - [Rate Limiting](https://aipatterns.dev/design-patterns/rate-limiting.md): Give each client a refillable budget of calls - take a token to proceed, refuse with 429 and a Retry-After when the bucket is empty - so one client's burst cannot spend everyone's capacity. - [Adapter](https://aipatterns.dev/design-patterns/adapter.md): Wrap an incompatible class in an object that exposes the interface your code expects, so you can use it without changing either side. - [Bridge](https://aipatterns.dev/design-patterns/bridge.md): Split a class that varies along two dimensions into two hierarchies joined by composition, so each side grows without multiplying subclasses. - [Composite](https://aipatterns.dev/design-patterns/composite.md): Treat single objects and nested groups of them through one interface, so code can walk a tree of any depth without checking node types. - [Decorator](https://aipatterns.dev/design-patterns/decorator.md): Wrap an object in another object with the same interface that adds behavior before or after delegating, so features stack without subclassing. - [Facade](https://aipatterns.dev/design-patterns/facade.md): Give a complex subsystem one small entry point for a common task, so callers stop orchestrating its classes and calling them in the right order. - [Flyweight](https://aipatterns.dev/design-patterns/flyweight.md): Share one immutable object for state that many objects have in common, and pass the per-object rest in, to cut memory when instances number in the millions. - [Proxy](https://aipatterns.dev/design-patterns/proxy.md): Put a stand-in with the same interface in front of an object to control access to it: create it lazily, check permissions, or reach it remotely. - [Extract Method](https://aipatterns.dev/refactoring/techniques/extract-method.md): Move a coherent fragment of a long function into its own well-named function and call it from the original place. - [Inline Method](https://aipatterns.dev/refactoring/techniques/inline-method.md): Replace calls to a function whose body is as clear as its name with the body itself, then delete the function. - [Extract Variable](https://aipatterns.dev/refactoring/techniques/extract-variable.md): Name a hard-to-read expression or sub-expression by assigning it to a well-named local variable. - [Inline Temp](https://aipatterns.dev/refactoring/techniques/inline-temp.md): Replace a temporary variable that holds a simple expression with the expression itself when the name adds nothing. - [Replace Temp with Query](https://aipatterns.dev/refactoring/techniques/replace-temp-with-query.md): Move the expression behind a temporary variable into its own method so every method in the class can ask for the value. - [Split Temporary Variable](https://aipatterns.dev/refactoring/techniques/split-temporary-variable.md): Give each distinct purpose its own variable when one local is reassigned to hold unrelated intermediate values. - [Remove Assignments to Parameters](https://aipatterns.dev/refactoring/techniques/remove-assignments-to-parameters.md): Stop reassigning a function parameter inside its body; copy it into a local variable and work on that instead. - [Replace Method with Method Object](https://aipatterns.dev/refactoring/techniques/replace-method-with-method-object.md): Turn a long method with tangled local variables into its own class, so the locals become fields and the body can be split freely. - [Substitute Algorithm](https://aipatterns.dev/refactoring/techniques/substitute-algorithm.md): Replace the body of a function with a clearer or simpler algorithm that produces the same results. - [Pull Up Field](https://aipatterns.dev/refactoring/techniques/pull-up-field.md): Move a field that every subclass declares in the same way into their shared superclass so it is defined once. - [Pull Up Method](https://aipatterns.dev/refactoring/techniques/pull-up-method.md): Move a method that is identical across subclasses into their superclass so the logic lives and changes in one place. - [Pull Up Constructor Body](https://aipatterns.dev/refactoring/techniques/pull-up-constructor-body.md): Move initialization code shared by subclass constructors into a superclass constructor and call it with super(). - [Push Down Method](https://aipatterns.dev/refactoring/techniques/push-down-method.md): Move a superclass method into the only subclasses that use it, so the superclass describes only what all subclasses share. - [Push Down Field](https://aipatterns.dev/refactoring/techniques/push-down-field.md): Move a superclass field into the subclasses that use it, so other subclasses stop carrying state they never touch. - [Extract Subclass](https://aipatterns.dev/refactoring/techniques/extract-subclass.md): Move features used only by some instances of a class into a new subclass, replacing the flag or nullable fields that marked them. - [Extract Superclass](https://aipatterns.dev/refactoring/techniques/extract-superclass.md): Create a shared superclass for two classes with overlapping fields and methods, and pull the common parts up into it. - [Extract Interface](https://aipatterns.dev/refactoring/techniques/extract-interface.md): Declare the subset of a class's methods that clients actually use as an interface, so clients depend on the contract instead of the class. - [Collapse Hierarchy](https://aipatterns.dev/refactoring/techniques/collapse-hierarchy.md): Merge a subclass into its superclass (or the reverse) when the two have become nearly identical and the split no longer earns its cost. - [Form Template Method](https://aipatterns.dev/refactoring/techniques/form-template-method.md): When subclass methods follow the same sequence of steps with different details, pull the sequence into the superclass and leave only the steps in subclasses. - [Replace Inheritance with Delegation](https://aipatterns.dev/refactoring/techniques/replace-inheritance-with-delegation.md): Turn a subclass that uses only part of its superclass into a class that holds an instance of it and forwards just the calls it needs. - [Replace Delegation with Inheritance](https://aipatterns.dev/refactoring/techniques/replace-delegation-with-inheritance.md): When a class forwards nearly every call to one delegate it truly is a kind of, make it a subclass of that delegate and delete the forwarding. - [Move Method](https://aipatterns.dev/refactoring/techniques/move-method.md): Move a method to the class whose data it uses most, and leave a delegating call or update the callers. - [Move Field](https://aipatterns.dev/refactoring/techniques/move-field.md): Move a field to the class that uses it most, updating every reader and writer to reach it there. - [Extract Class](https://aipatterns.dev/refactoring/techniques/extract-class.md): Split a class that does two jobs by moving one job's fields and methods into a new class it holds a reference to. - [Inline Class](https://aipatterns.dev/refactoring/techniques/inline-class.md): Fold a class that does too little into the class that uses it, moving its fields and methods across and deleting it. - [Hide Delegate](https://aipatterns.dev/refactoring/techniques/hide-delegate.md): Add a method on the server object that forwards to its delegate, so clients stop navigating through it to reach the delegate. - [Remove Middle Man](https://aipatterns.dev/refactoring/techniques/remove-middle-man.md): Let clients call the delegate directly when a class does little more than forward calls to it. - [Introduce Foreign Method](https://aipatterns.dev/refactoring/techniques/introduce-foreign-method.md): Add a helper in your own code that takes an instance of a class you cannot change and provides the method it lacks. - [Introduce Local Extension](https://aipatterns.dev/refactoring/techniques/introduce-local-extension.md): Wrap or subclass a class you cannot change in your own class that adds the methods you need. - [Self Encapsulate Field](https://aipatterns.dev/refactoring/techniques/self-encapsulate-field.md): Access a field through its own getter and setter even inside the class, so subclasses or later changes can intercept the access. - [Replace Data Value with Object](https://aipatterns.dev/refactoring/techniques/replace-data-value-with-object.md): Turn a primitive field that has grown rules and companions into a small class that owns its data and behavior. - [Change Value to Reference](https://aipatterns.dev/refactoring/techniques/change-value-to-reference.md): Replace many identical copies of an entity with one shared instance looked up from a registry, so updates are seen everywhere. - [Change Reference to Value](https://aipatterns.dev/refactoring/techniques/change-reference-to-value.md): Make a small shared object immutable and compare it by content, so it can be copied freely instead of tracked by identity. - [Replace Array with Object](https://aipatterns.dev/refactoring/techniques/replace-array-with-object.md): Replace an array whose positions hold different kinds of data with an object that has a named field for each. - [Duplicate Observed Data](https://aipatterns.dev/refactoring/techniques/duplicate-observed-data.md): Move domain data out of a UI class into a domain object, and keep the UI in sync with it through observation. - [Change Unidirectional Association to Bidirectional](https://aipatterns.dev/refactoring/techniques/change-unidirectional-association-to-bidirectional.md): Add a back-reference when each of two classes needs to navigate to the other, and keep both sides in sync through one owner. - [Change Bidirectional Association to Unidirectional](https://aipatterns.dev/refactoring/techniques/change-bidirectional-association-to-unidirectional.md): Remove a back-reference that no code needs any more, so two classes stop depending on each other. - [Replace Magic Number with Symbolic Constant](https://aipatterns.dev/refactoring/techniques/replace-magic-number-with-symbolic-constant.md): Give a literal number or string with special meaning a named constant, and use the name everywhere the value appears. - [Encapsulate Field](https://aipatterns.dev/refactoring/techniques/encapsulate-field.md): Make a public field private and give clients accessor methods, so the class controls how its data is read and changed. - [Encapsulate Collection](https://aipatterns.dev/refactoring/techniques/encapsulate-collection.md): Stop a getter from handing out a mutable internal collection; return a read-only view and add methods to add and remove items. - [Replace Type Code with Class](https://aipatterns.dev/refactoring/techniques/replace-type-code-with-class.md): Replace a set of string or number codes that don't affect behavior with a dedicated type, so only valid codes can be used. - [Replace Type Code with Subclasses](https://aipatterns.dev/refactoring/techniques/replace-type-code-with-subclasses.md): Turn each value of an immutable type code that drives conditionals into a subclass, and move the branch logic into overrides. - [Replace Type Code with State/Strategy](https://aipatterns.dev/refactoring/techniques/replace-type-code-with-state-strategy.md): Move behavior that depends on a type code into separate state or strategy objects that the host holds and can swap at runtime. - [Replace Subclass with Fields](https://aipatterns.dev/refactoring/techniques/replace-subclass-with-fields.md): Collapse subclasses that differ only in the constants their methods return into fields on the parent, then delete the subclasses. - [Decompose Conditional](https://aipatterns.dev/refactoring/techniques/decompose-conditional.md): Move a complex condition and each of its branches into well-named functions so the decision reads as intent instead of arithmetic. - [Consolidate Conditional Expression](https://aipatterns.dev/refactoring/techniques/consolidate-conditional-expression.md): Merge a run of separate checks that all lead to the same result into one condition with a name that states the shared rule. - [Consolidate Duplicate Conditional Fragments](https://aipatterns.dev/refactoring/techniques/consolidate-duplicate-conditional-fragments.md): Move code that runs identically in every branch of a conditional to before or after the conditional so each branch holds only what differs. - [Remove Control Flag](https://aipatterns.dev/refactoring/techniques/remove-control-flag.md): Replace a boolean variable that steers a loop or function with break, continue or return so control flow is explicit. - [Replace Nested Conditional with Guard Clauses](https://aipatterns.dev/refactoring/techniques/replace-nested-conditional-with-guard-clauses.md): Handle special and invalid cases first with early returns so the normal path runs flat at the end of the function. - [Replace Conditional with Polymorphism](https://aipatterns.dev/refactoring/techniques/replace-conditional-with-polymorphism.md): Replace a switch on an object's type or kind with one class per case that overrides a shared method, so new cases add code instead of editing it. - [Introduce Null Object](https://aipatterns.dev/refactoring/techniques/introduce-null-object.md): Replace repeated null checks for a missing collaborator with an object that implements the same interface and does the safe default. - [Introduce Assertion](https://aipatterns.dev/refactoring/techniques/introduce-assertion.md): State an assumption the code already relies on as an explicit check that fails fast, instead of leaving it in a comment or in the reader's head. - [Rename Method](https://aipatterns.dev/refactoring/techniques/rename-method.md): Change a method's name to say what it does, using a forwarding alias when callers cannot all be updated at once. - [Add Parameter](https://aipatterns.dev/refactoring/techniques/add-parameter.md): Give a method a new parameter when it needs data it cannot reach, migrating callers through a temporary overload or default value. - [Remove Parameter](https://aipatterns.dev/refactoring/techniques/remove-parameter.md): Delete a parameter the method body no longer uses, updating every caller and override so the signature states only real dependencies. - [Separate Query from Modifier](https://aipatterns.dev/refactoring/techniques/separate-query-from-modifier.md): Split a method that both returns a value and changes state into a side-effect-free query and a separate command. - [Parameterize Method](https://aipatterns.dev/refactoring/techniques/parameterize-method.md): Merge several methods that do the same thing with different literal values into one method that takes the value as a parameter. - [Replace Parameter with Explicit Methods](https://aipatterns.dev/refactoring/techniques/replace-parameter-with-explicit-methods.md): Split a method that branches on a flag or enum argument into one clearly named method per value. - [Preserve Whole Object](https://aipatterns.dev/refactoring/techniques/preserve-whole-object.md): Pass the object itself instead of several values pulled out of it, so the method signature stays stable as needs change. - [Replace Parameter with Method Call](https://aipatterns.dev/refactoring/techniques/replace-parameter-with-method-call.md): Stop passing a value the method can obtain itself; have the method call the query directly and drop the parameter. - [Introduce Parameter Object](https://aipatterns.dev/refactoring/techniques/introduce-parameter-object.md): Replace a group of parameters that always travel together with one object type, then move behavior on that group into it. - [Remove Setting Method](https://aipatterns.dev/refactoring/techniques/remove-setting-method.md): Delete the setter for a field that should only be set at creation, and assign it in the constructor so it cannot change later. - [Hide Method](https://aipatterns.dev/refactoring/techniques/hide-method.md): Reduce a method's visibility to private or protected when nothing outside the class needs it, shrinking the public surface. - [Replace Constructor with Factory Method](https://aipatterns.dev/refactoring/techniques/replace-constructor-with-factory-method.md): Wrap object creation in a named static or module function when a plain constructor cannot express intent, pick a subtype, or reuse instances. - [Replace Error Code with Exception](https://aipatterns.dev/refactoring/techniques/replace-error-code-with-exception.md): Throw a typed exception instead of returning a sentinel such as -1 or false, so failures cannot be silently ignored by callers. - [Replace Exception with Test](https://aipatterns.dev/refactoring/techniques/replace-exception-with-test.md): Check a predictable condition before the call instead of catching the exception it would throw, keeping exceptions for real failures. - [Consolidate Tools](https://aipatterns.dev/refactoring/techniques/consolidate-tools.md): Merge thin, overlapping tools into one task-shaped tool that returns only the fields the task reads, and describe when to use it - so consumers pick right the first time and stop chaining calls. - [Long Method](https://aipatterns.dev/refactoring/smells/long-method.md): A function that does several jobs in a row and has grown too long to read, name or test as one unit. - [Large Class](https://aipatterns.dev/refactoring/smells/large-class.md): A class with too many fields, methods or responsibilities, so every change risks breaking something unrelated inside it. - [Primitive Obsession](https://aipatterns.dev/refactoring/smells/primitive-obsession.md): Domain concepts like money, emails, IDs or statuses are passed around as raw strings and numbers, so their rules get re-checked everywhere. - [Long Parameter List](https://aipatterns.dev/refactoring/smells/long-parameter-list.md): A function takes so many parameters that callers mix up their order and every new option changes every call site. - [Data Clumps](https://aipatterns.dev/refactoring/smells/data-clumps.md): The same group of variables travels together through fields and parameters, signaling a missing object that should own them. - [Divergent Change](https://aipatterns.dev/refactoring/smells/divergent-change.md): One class gets edited for many unrelated reasons, so every kind of change lands in the same file and collides with every other kind. - [Shotgun Surgery](https://aipatterns.dev/refactoring/smells/shotgun-surgery.md): One logical change forces small edits in many classes, so one missed edit ships an inconsistent system. - [Parallel Inheritance Hierarchies](https://aipatterns.dev/refactoring/smells/parallel-inheritance-hierarchies.md): Every new subclass in one hierarchy forces a matching subclass in another, so two trees must always grow in lockstep. - [Feature Envy](https://aipatterns.dev/refactoring/smells/feature-envy.md): A method reads and computes on another object's data more than its own. Move the logic to where the data lives. - [Inappropriate Intimacy](https://aipatterns.dev/refactoring/smells/inappropriate-intimacy.md): Two classes reach into each other's private fields and internals. Cut the back-and-forth by moving members or narrowing what each exposes. - [Message Chains](https://aipatterns.dev/refactoring/smells/message-chains.md): Client code walks a chain like a.getB().getC().getD() to reach what it needs, coupling itself to every link in the path. - [Middle Man](https://aipatterns.dev/refactoring/smells/middle-man.md): A class mostly forwards calls to another object and adds nothing. Let clients talk to the real object or fold the wrapper away. - [Comments](https://aipatterns.dev/refactoring/smells/comments.md): Comments that explain what unclear code does are a sign the code should be renamed or restructured so it explains itself. - [Duplicate Code](https://aipatterns.dev/refactoring/smells/duplicate-code.md): The same logic appears in two or more places, so every fix and change must be made several times and the copies drift apart. - [Lazy Class](https://aipatterns.dev/refactoring/smells/lazy-class.md): A class does too little to justify the file, name and indirection it costs; fold it into its caller or delete it. - [Data Class](https://aipatterns.dev/refactoring/smells/data-class.md): A class holds fields and accessors but no behavior, while other classes reach in to do the work that belongs to it. - [Dead Code](https://aipatterns.dev/refactoring/smells/dead-code.md): Variables, parameters, branches, methods or classes that nothing uses still sit in the codebase, costing reading time and misleading readers. - [Speculative Generality](https://aipatterns.dev/refactoring/smells/speculative-generality.md): Abstractions, hooks and parameters built for future needs that never arrived make code harder to read without serving any current use. - [Switch Statements](https://aipatterns.dev/refactoring/smells/switch-statements.md): The same switch or if-chain over a type code is repeated across the codebase, so adding one case means editing every copy. - [Temporary Field](https://aipatterns.dev/refactoring/smells/temporary-field.md): A field that is set and meaningful only during one operation or in one special case, and is empty or stale the rest of the time. - [Refused Bequest](https://aipatterns.dev/refactoring/smells/refused-bequest.md): A subclass inherits methods or data it does not want, overriding them to throw or do nothing, so the hierarchy lies about what it can do. - [Alternative Classes with Different Interfaces](https://aipatterns.dev/refactoring/smells/alternative-classes-with-different-interfaces.md): Two classes do the same job but expose different method names or signatures, so callers cannot swap one for the other. - [Incomplete Library Class](https://aipatterns.dev/refactoring/smells/incomplete-library-class.md): A library type lacks a method you need and you cannot edit it, so helper logic for it is scattered across your code. - [Thin Tool Wrapper](https://aipatterns.dev/refactoring/smells/thin-tool-wrapper.md): A tool for an agent or API consumer that passes an upstream operation through raw - one endpoint, one tool, provider-shaped payloads - so every real task becomes a chain of calls over low-signal data.