Chess, Business Central, and vibe coding AL!

This week in AL land, it’s all about chess, Business Central and vibe coding chess in Business Central. Check it out:

https://youtu.be/SP1UJNjTN7s

In this video, Erik explores the intersection of chess, Business Central, and AI-assisted coding (or “vibe coding”) by attempting to have Claude build a fully functional chess application as a Business Central control add-in. Along the way, he plays a correspondence chess game against fellow MVP AJ Kalfman and shares insights about why chess makes an excellent test problem for AI code generation.

The Business Central Chess Club

Erik is a member of the Business Central Chess Club on chess.com, which currently has 55 members. He’s playing an ongoing game against AJ Kalfman, a well-known MVP from the Netherlands, and as Erik freely admits, AJ usually beats him. Erik floats the idea of organizing a chess tournament at Directions and invites viewers to express interest in the comments.

Why Chess as an AI Coding Test

Chess is a well-known (though not solved) problem, and Erik uses it as his go-to benchmark for testing different AI coding approaches. The key insight is that chess has an enormous amount of training data available — thousands of chess engines have been written over the decades, including one that famously runs on a ZX81 with just 1K of RAM. This abundance of training material means AI models can actually produce reasonable chess code, unlike more niche domains like Business Central AL, where training data is comparatively minuscule.

This contrast highlights an important truth about vibe coding: AI performs dramatically better on well-known, well-documented problems than on domain-specific ones.

The Vibe Coding Experiment

Erik already has a semi-working chess app in Business Central that was partially AI-generated but required manual intervention. The chess pieces are rendered using Unicode characters for the chess pieces (both black and white), which makes display surprisingly straightforward. The app has a chess engine codeunit that calculates computer moves, and a user control for the board display.

The Prompt

Erik crafts a prompt for Claude to generate a complete Business Central control add-in:

Create a Business Central control add-in — a custom JavaScript-based control that will display an interactive chess board. The board should have an event to channel moves made on the board by the user back into AL, where there’s an engine that calculates computer moves, and a way for AL to make the moves on the board. All parameters should be integers for columns and rows and should match the chess orientation. So A1 is 1,1 and H8 is 8,8. The board should look nice and use Business Central colors.

One of the key lessons Erik emphasizes about vibe coding is that when you’re generating separate components (A, B, and C) that need to work together, you must be very specific about how they interact — especially around data formats and coordinate systems.

What Claude Generated

Claude generated an HTML demonstration file, an AL control add-in interface definition, a page, and even an optional table to store chess game data. However, the initial output had several problems:

  • The HTML file was a standalone demonstration, not the actual JavaScript/CSS files needed for a Business Central control add-in
  • The board had black pieces where white should be and vice versa
  • The square colors were wrong (A1 should be a dark square)
  • The board was drawn upside down (row 8 should be at the top)

Iterating with Claude

Erik had to go back and explicitly tell Claude that the control add-in references JS and CSS files that weren’t actually created:

The control add-in is mentioning two JS files and a CSS file. You have not created those. The HTML file created earlier was for demonstration. In Business Central, we need separate files.

Claude then generated the required files: startup.js, chessboard.js, and chessboard.css. Erik manually created each file and placed them in the project — noting that in an integrated tool like Cursor, this would happen automatically.

The App Structure

The project configuration shows a straightforward Business Central app setup:

{
  "id": "b419d778-fcf5-45ee-9914-64b957f65f8c",
  "name": "BC Chess",
  "publisher": "Hougaard.com",
  "version": "1.0.0.0",
  "platform": "17.0.0.0",
  "application": "17.0.0.0",
  "idRanges": [
    {
      "from": 57300,
      "to": 57349
    }
  ],
  "runtime": "6.0"
}

The architecture consists of several components working together:

  • Chess Engine (Codeunit) — An AL codeunit that calculates computer moves. This was largely AI-generated, though Erik noted some bugs around the difference between SubString and Format.
  • Control Add-in — The AL interface definition that declares the JavaScript control, its events (like OnPieceMoved and OnReset), and its methods (like MovePiece).
  • Chess Page — The AL page that hosts the control and wires up the chess engine to the board’s events.
  • JavaScript/CSS — The front-end rendering of the chess board using Unicode chess piece characters.

Debugging AI-Generated Code

After assembling all the pieces, Erik ran into a classic vibe coding problem: the computer’s move wasn’t being reflected on the board. The MovePiece function appeared to not be called at all. Erik added console logging to the JavaScript:

console.log("movePiece", fromRow, fromCol, toRow, toCol);

Through debugging, he discovered a case sensitivity issue — the AL side was calling MovePiece (with an uppercase P) while the JavaScript had registered it with a lowercase method name. This is a common pitfall when AI generates code across language boundaries where casing conventions differ.

Erik also noted that JavaScript compilation in Business Central is essentially non-existent — the compiler just packages the JS files into the app without validating them. There’s no check that the methods referenced in the AL control add-in interface actually exist in the JavaScript. This makes debugging the integration between AL and JavaScript particularly challenging.

He described this as the classic vibe coding conundrum: “The AI has written some code and it looks like it almost works, and then it doesn’t work, and you have no clue what’s going on because it’s not your code — it’s AI code.”

Key Takeaways

  • Coordinate system mismatches are a recurring problem when AI generates interconnected components — one part used 0-8 indexing while another used 1-8 chess notation.
  • Case sensitivity across AL and JavaScript can silently break integration without any compiler warnings.
  • AI excels at well-documented problems like chess but struggles with niche domains like AL development, where training data is limited.
  • Be extremely specific in your prompts about how generated components should interface with each other.
  • Integrated tools like Cursor would streamline the file creation and placement workflow significantly compared to manual copy-paste from Claude’s web interface.

Get Involved

Erik encourages viewers to try this challenge themselves — build a chess app in Business Central using any AI tool of their choice (Claude, Copilot, Cursor, etc.) and share the results. The source code is available in Erik’s GitHub repository (linked in the video description), and contributions to make it fully functional are welcome.

And if you play chess, join the Business Central Chess Club on chess.com to take on those pesky MVPs!