/aldc:skill-debugfrom ALDC for Claude Code
Provides systematic debugging and diagnostics for AL Business Central: runtime errors, logic bugs, intermittent failures, performance bottlenecks, and configuration issues. Covers snapshot debugging, CPU profiling, telemetry analysis, and event subscriber troubleshooting.
Ships in ALDC for Claude Code. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
For BC29 AL0926 section-order errors or new isolation behavior, read the relevant sections of AL18 capability checks. Use actual compiler/runtime evidence and keep compilation distinct from execution.
Systematic diagnosis and root cause analysis for AL Business Central issues: runtime errors, logic bugs, intermittent failures, performance bottlenecks, and configuration problems.
This skill should be loaded when:
Select the right tool before starting:
| Issue Type | Strategy | Tool |
|---|---|---|
| Consistent runtime error | Standard debugger | al_debug |
| Already deployed code | Debug without publish | al_debug |
| Rapid dev cycle | Incremental publish | al_publish (incremental) |
| Intermittent / hard-to-reproduce | Snapshot debugging | al_snapshotdebugging |
| Slow performance | CPU profiling | VS Code command (not an agent tool) |
| Auth / symbols / build | Configuration troubleshoot | See Workflow Step 2b |
| Copilot AI feature | Agent session debug | launch.json with clientType: Agent |
Scenario: "Value is wrong after posting"
1. Set breakpoint at final location (where value is wrong)
2. Work backwards to find where value is set
3. Use `usages` tool to find all assignments
4. Set breakpoints at each assignment point
5. Step through to find which execution path is taken
6. Inspect conditions and variable states at each point
Scenario: "My event subscriber doesn't execute"
1. Verify subscriber signature exactly matches publisher (name, parameters, types)
2. Check SkipOnMissingLicense and SkipOnMissingPermission attributes
3. Confirm the extension containing the publisher is active and published
4. Set breakpoint inside subscriber body
5. Verify the publisher event is actually being raised (breakpoint in publisher)
6. Check if IsHandled = true is set before your subscriber runs
7. Inspect subscriber execution order (EventPriority)
// ❌ N+1 pattern — common cause of slow pages
repeat
Item.Get(SalesLine."No."); // DB call inside loop
SalesLine.Amount := Item.Price * SalesLine.Quantity;
until SalesLine.Next() = 0;
// ✅ Use SetLoadFields + single pass
SalesLine.SetLoadFields("No.", Quantity, Amount);
if SalesLine.FindSet() then
repeat
// ...
until SalesLine.Next() = 0;
CPU profile analysis focus:
⚠️ HUMAN GATE: Snapshots may capture sensitive runtime data.
Before initializing:
1. Confirm what data will be captured
2. Security review for sensitive information
3. Obtain explicit user approval
Commands (one tool — `al_snapshotdebugging` — covers initialize / finish / view):
al_snapshotdebugging (initialize) ← start capture session
[reproduce scenario 10-20 times]
al_snapshotdebugging (finish) ← end capture
al_snapshotdebugging (view) ← view and compare
Compare snapshots between success and failure cases:
- Variable values at failure point
- Timing differences
- Execution paths taken
- Data state variations
Read existing plans context first:
.claude/plans/memory.md ← project state and recent decisions
.claude/plans/*-diagnosis.md ← previous debug sessions (similar issues)
Gather issue information:
Stop criterion: can reproduce the issue consistently (≥80% success rate).
search and usages toolsAuthentication failures (401/403, cannot download symbols):
⚠️ HUMAN GATE: Clearing credentials disconnects active sessions.
Confirm impact and obtain approval before clearing the credentials cache
(a VS Code command, not an agent tool).
Then re-authenticate and verify launch.json authentication method.
Missing symbols (unresolved references, red squiggles):
al_downloadsymbols ← first attempt
al_downloadsymbols (globalSourcesOnly) ← if no BC server connection is available
al_build ← verify compilation
Check app.json dependencies version alignment.
Build errors — common codes:
AL0896 — Recursive FlowField: map dependency graph, break circular chainAL0185 — Object ID conflict: check ID range in app.json, no duplicatesAL0118 — Field length mismatch: align extension field length with base tablePublishing failures: check environment connectivity, extension version increment, dependency resolution via al_packages.
Identify the exact point of failure and — critically — WHY it occurs:
Common AL root causes by scenario:
| Symptom | Root Cause Candidates |
|---|---|
| Record Not Found | Wrong key values, filters blocking read, wrong company context, permission on read |
| FlowField wrong value | CalcFields not called, incorrect CalcFormula filters, circular dependency (AL0896) |
| OnValidate not firing | Direct assignment without Validate(), IsHandled = true in subscriber, disabled trigger |
| Custom event not firing | Signature mismatch, wrong ObjectType/ObjectId, publisher not raising event, compilation error in subscriber |
| Slow page | Missing SetLoadFields, N+1 loop, FlowField CalcFormula too complex, missing index/key |
| Intermittent failure | Race condition, timing dependency, data-state dependency, environment-specific |
Create .claude/plans/<issue-kebab-case>-diagnosis.md before proposing any fix:
# Debug Session: <Issue Title>
**Date**: YYYY-MM-DD
**Severity**: Critical / High / Medium / Low
**Status**: Investigating → Diagnosed → Fixed → Verified
## Issue Summary
[Brief description]
## Symptoms
- Expected: [what should happen]
- Actual: [what happens — include exact error text]
## Reproduction Steps
1. [Step]
2. [Step]
**Reproducibility**: Always / Sometimes / Rare
## Root Cause
[Technical explanation with evidence — code snippet, line reference]
## Recommended Fix
[Specific solution. Short-term hotfix + long-term if needed]
## Testing Strategy
- Unit: [what to mock/test]
- Regression: [related functionality to verify]
## Next Steps
1. [Action]
2. [Action]
File naming: sales-posting-error-diagnosis.md, slow-customer-list-diagnosis.md.
al-implementer (simple) or via al-conductor TDD cycle (complex refactor)Clean up: remove debugging artifacts, breakpoints, and temporary logging from code.
al-implementer or via al-conductorskill-performance.mdskill-events.mdskill-permissions.mdWhat SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub javiarmesto/aldc-al-development-collection --plugin aldc25 skills in this plugin
/al-buildBuild, package, and deploy AL extensions to Business Central environments. ALDC workflow (Copilot prompt al-build); invoke explicitly./al-context-createGenerate or update context.md file documenting project structure, architecture, and key patterns for AI assistants and developers. ALDC workflow (Copilot prompt al-context.create); invoke explicitly./al-initializeInitialize AL development environment and workspace for Business Central. ALDC workflow (Copilot prompt al-initialize); invoke explicitly.Other plugins' skills for the same job