@oliexe12/al-design-patterns
v0.1.0
Published
Search, compare, and retrieve AL design patterns through a CLI or MCP server.
Readme
Design Patterns in AL
This repository contains knowledge and examples for design patterns in the AL programming language. It supports both people and LLM-based tools.
The design pattern classification follows Refactoring.Guru.
Each pattern includes:
- a short explanation of the problem,
- a self-contained and readable AL example,
- structured metadata in the central catalog,
- stable paths that other workflows can use to retrieve the content.
Pattern catalog
| Group | Purpose | Included patterns |
| --- | --- | --- |
| Creational patterns (creational) | Control how objects are created | Factory Method, Abstract Factory, Builder, Prototype, Singleton |
| Structural patterns (structural) | Organize relationships between components | Facade, Adapter, Bridge, Composite, Decorator, Flyweight, Proxy |
| Behavioral patterns (behavioral) | Distribute responsibilities and communication | Chain of Responsibility, Command, Iterator, Mediator, Memento, Observer, State, Strategy, Template Method, Visitor |
Additional AL tags describe the practical use, such as orchestration, boundary, or coupling-reduction.
Quick start
Install Node.js 22 or later. You can then run the CLI without a permanent installation:
npx --yes --package=@oliexe12/al-design-patterns dp-al search "runtime algorithm"Install the package globally if you use it often:
npm install --global @oliexe12/al-design-patterns
dp-al search "runtime algorithm"The CLI returns JSON. Use these commands to explore the catalog:
dp-al list
dp-al search "change behavior at runtime" --limit 3
dp-al get strategy --include documentation,source
dp-al compare strategy state template-method
dp-al recommend --choose behavioral-pressure --choose algorithm-pressure --choose strategy
dp-al validateUse dp-al search when you know the problem but not the pattern. Use dp-al get when you know the pattern ID.
MCP server
The MCP server lets an LLM search and read the pattern catalog. It provides four read-only tools:
search_patternsrecommend_patternget_patterncompare_patterns
Add this server to an MCP client:
{
"mcpServers": {
"al-design-patterns": {
"command": "npx",
"args": [
"--yes",
"--package=@oliexe12/al-design-patterns",
"dp-al-mcp"
]
}
}
}Use .vscode/mcp.json for VS Code. Use mcp.example.json for clients that use the mcpServers format.
Restart the MCP client after you add the configuration. The client starts and updates the package through npx.
Browse the examples
Each pattern page explains the problem, roles, trade-offs, and AL implementation. Select a pattern from the catalog above and follow its documented entry point.
Run pwsh scripts/Select-DesignPattern.ps1 for an interactive local selector. See the selection guide for the complete decision tree.
The examples target Business Central Application 28 and AL runtime 17. Use the AL extension to download symbols and compile the app.
Repository structure
src/Patterns/<Group>/<Pattern>/ executable AL code
patterns/<Group>/<Pattern>/ documentation for people and LLMs
knowledge/catalog.json canonical machine-readable catalog
knowledge/pattern.schema.json JSON Schema for catalog entries
scripts/Test-KnowledgeBase.ps1 consistency check
tools/ shared CLI and MCP implementationContributing
Each new pattern must include documentation, code, and a catalog entry. See CONTRIBUTING.md for details.
License
This project uses the MIT License.
Sources
The descriptions and examples are original. Each pattern lists its technical sources, including Refactoring.Guru.
