web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Dynamics 365 Community / Blogs / New Dynamic, LLC / AI-Assisted Code Review for...

AI-Assisted Code Review for Microsoft Dynamics 365: How To Use Claude Code

Travis South Profile Picture Travis South

AI-assisted code review for Dynamics 365 is becoming increasingly common in modern development workflows. Tools like Claude Code can help support Dynamics 365 code review by surfacing potential issues before they reach production. However, generic AI code review tools often miss the platform-specific patterns that matter most in Dataverse and Dynamics 365 environments. Plugins, Fetch XML queries, client-side scripts, and PCF controls introduce risks that traditional code reviews or general AI models may not recognize.

Claude Code is Anthropic’s command line tool that lets you delegate coding tasks to Claude directly from your terminal. One of its strengths is performing code reviews, and you can customize exactly what it looks for by providing a markdown file with your review criteria. In this article, I will walk through how to set this up for a D365 code base. This approach is particularly useful for Dynamics 365 developers, solution architects, and technical consultants responsible for reviewing plugins, web resources, PCF controls, or Power Automate logic.

What Is AI-Assisted Code Review in Microsoft Dynamics 365

AI-assisted code review in Microsoft Dynamics 365 and Dataverse development uses large language models to analyze source code and identify potential issues before deployment. Because Dynamics 365 runs on Dataverse within the Power Platform, development patterns and performance considerations often span all three layers. These tools can review plugins, client scripts, and Power Platform components for common problems such as inefficient queries, missing exception handling, and platform-specific anti-patterns. When combined with custom review instructions tailored to Dynamics 365 development practices, AI becomes a fast first-pass reviewer that helps teams maintain consistent quality across projects.

If you are interested in another way AI can help enforce development standards in Dynamics 365, I also wrote about using Claude to maintain consistency across JavaScript libraries in a separate article.

Why Custom Code Review Instructions Matter

Out of the box, any AI assistant can look at code and provide general feedback about naming conventions, code structure, and potential bugs. But Dynamics 365 development has its own set of concerns that require specific knowledge about the platform. A plugin that looks fine from a C# perspective might have serious issues from a Dataverse perspective, like missing registered images, improper exception handling that breaks the transaction, or inefficient queries that timeout in production.

In Dynamics 365 environments, this context becomes critical because code that compiles successfully may still create performance issues or unintended behavior once it runs inside the Dataverse execution pipeline. In many Dynamics implementations, these issues only appear during testing or production workloads. By creating a markdown file with D365-specific review criteria, you give Claude Code the context it needs to catch platform-specific issues in Dynamics 365 plugins, Dataverse queries, and Power Platform customizations.

Setting Up Your Code Review Instructions File

Consistent code review standards help prevent performance issues and maintain long-term platform stability. First, create a markdown file in your repository called REVIEW_INSTRUCTIONS.md. This file will contain the specific items you want Claude Code to check during reviews. Here is a template I use for Microsoft Dynamics 365 projects:

# D365 Code Review Checklist

## Plugin Development (C#)

When reviewing plugin code, check for the following:

– Verify IPluginExecutionContext is used correctly and not stored in class-level variables
– Confirm InputParameters and OutputParameters are accessed with proper null checks
– Check that preEntityImages and postEntityImages are registered and accessed correctly
– Ensure TracingService is used for logging instead of Debug.WriteLine or Console.WriteLine
– Verify exceptions are thrown as InvalidPluginExecutionException to surface messages to users
– Check for proper use of IOrganizationService vs IOrganizationServiceFactory for cross-user operations
– Look for RetrieveMultiple calls without pagination that could timeout on large datasets
– Confirm transactions are not being committed manually—let the pipeline handle it
– Check for infinite loop prevention when updating the same entity that triggered the plugin
– Verify early-bound vs late-bound entity usage is consistent throughout the project

JavaScript Web Resources

When reviewing JavaScript web resources, check for:

– Proper use of formContext instead of deprecated Xrm.Page
– Null checks before accessing form attributes and controls
– Async/await patterns for Web API calls instead of callback chains
– Proper error handling with user-friendly notifications via formContext.ui.setFormNotification
– Check that getValue() results are validated before use
– Verify event handlers are registered in the form designer, not hardcoded in onload
– Look for hardcoded GUIDs or schema names that should be in a constants file

PCF Controls (TypeScript)

When reviewing PCF controls, check for:

– Proper cleanup in the destroy() method to prevent memory leaks
– Correct implementation of getOutputs() for bound properties
– Verify updateView() handles null or undefined context gracefully
– Check that external libraries are loaded correctly via ControlManifest
– Confirm the control does not make direct API calls—use provided context methods

FetchXML and OData Queries

When reviewing queries, check for:

– Appropriate use of filtering to limit result sets
– Pagination implementation for large datasets using paging cookies
– Proper attribute selection instead of retrieving all columns
– Link-entity joins that could cause cartesian products
– Aggregate queries that might timeout on large tables

Power Automate Expressions

When reviewing flow expressions embedded in solution files:

– Check for null handling with coalesce() or conditional expressions
– Verify date/time formatting matches expected regional settings
– Look for hardcoded environment URLs that will break on deployment
– Confirm error handling with Configure Run After settings

Running the Code Review

With your instructions file in place, you can run Claude Code and point it to both your code and your review instructions. From your terminal, navigate to your repository and run:

claude review src/Plugins/AccountPlugin.cs –instructions REVIEW_INSTRUCTIONS.md

When you run the review, Claude Code analyzes the file against your review criteria and highlights potential issues. In practice, you can run this against individual files while developing or against entire directories during broader code reviews.

Customizing for Your Team

The review instructions file above is a starting point. Teams should expand it with project-specific standards such as naming conventions, documentation requirements, security policies, and integration patterns.

For example, one project required reviewing front-end scripts for slow loading times, so I added checks focused on Web API calls and other performance-impacting patterns. Keep this file in your repository root so it evolves with your codebase. Everyone on the team can contribute to it, and the more specific your instructions become, the more useful the reviews.

Code Review Best Practices

In most Dynamics projects, the goal is not to replace experienced developers or architects with automation. Instead, the goal is to create a faster feedback loop so common issues are caught earlier while experienced reviewers focus on architecture, performance, and long-term maintainability.

  1. Start with a focused checklist and expand it as you encounter new issues.
  2. Include examples of both good and bad patterns as Claude Code uses these to understand what you are looking for.
  3. Run automated reviews as part of your CI/CD pipeline to catch issues before human reviewers.
  4. Update your instructions file whenever you fix a bug that a review should have caught.

Microsoft’s Power Platform Application Lifecycle Management guidance provides a helpful framework for maintaining consistent development and deployment practices across environments.

Key Takeaways for Microsoft Dynamics Development Teams

Code reviews will always require human judgment, especially when evaluating architecture decisions and business logic in complex Dynamics environments. However, structured AI-assisted reviews can remove much of the repetitive work involved in catching common platform issues.

By combining a Dynamics-specific checklist with tools like Claude Code, development teams can surface problems earlier, reinforce Power Platform development standards, and stay aligned with Dynamics 365 development best practices. In practice, AI becomes a useful review assistant that improves consistency while allowing senior developers and architects to focus on higher-value design decisions.

AI-assisted code review is not a replacement for experienced Dynamics architects, but it is quickly becoming a practical part of modern Dynamics 365, Dataverse, and Power Platform development workflows. In many Dynamics implementations, subtle performance or plugin execution issues only appear under real data loads. Structured AI reviews help surface those risks earlier while experienced developers remain responsible for final architecture decisions.

AI-Assisted Code Review for Microsoft Dynamics 365: How To Use Claude Code to Improve Power Platform Plugins and Dataverse Development Joshua Kranhold Senior Consultant New Dynamic

Working with New Dynamic

New Dynamic is a Microsoft Solutions Partner focused on the Dynamics 365 Customer Engagement and Power Platforms. Our team of dedicated professionals strives to provide first-class experiences incorporating integrity, teamwork, and a relentless commitment to our client’s success.
Contact Us today to transform your sales productivity and customer buying experiences.

Comments