AI automatic code review
DataWorks AI Assistant checks code review requests against your team's internal code review standards, makes decisions, and writes the results back automatically. When your team already has explicit coding standards but checking every request manually is slow and error-prone, provide the review standards and AI Assistant uploads them, runs the checks, and writes the results back, which replaces the repetitive part of manual review.
Two usage modes
AI automatic code review supports two usage modes. Select one based on your scenario:
Item | Proactive review | Scheduled automatic review |
Trigger method | User-initiated | Triggered on a schedule |
Execution mode | Human-AI collaboration | Fully automatic |
Critical violation handling | Pauses execution and waits for manual confirmation | AI rejects the request automatically (default; can be configured to require manual confirmation or to only display the findings) |
Applicable scenarios | First use, debugging standards, a small number of reviews | Daily operations, a large number of review requests |
SKILL required first | No (you can upload the standards directly) | Yes (you must create a SKILL first) |
For first use, verify the effect of your standards with proactive review. After the results meet your expectations, save the process as a SKILL and configure scheduled review. The recommended path is as follows:
Prepare review standards -> Proactive review (verify the effect)
|
Results as expected? -> Save as a SKILL -> Configure scheduled automatic reviewPrerequisites
Before you use AI automatic code review, make sure that the following requirements are met:
A DataWorks AI Assistant instance is created. If you have not created one, see Use the AI assistant service.
On the Skill Management tab of the AI Assistant instance details page, filter the SKILL list by the System type, find
DataWorks scenario-based governance inspection, and enable it.Make sure that the DataWorks edition in the current region is Professional Edition or Enterprise Edition.
To block the deployment of non-compliant code, we recommend that you enable the mandatory code review switch in the development settings of the target workspace.
Prepare the code review standard
Write a structured code review standard document in Markdown format based on your team's rules and business specifications. This document serves as the review criteria for AI Assistant. The review capability of AI Assistant depends on the quality of the standard. We recommend that the standard include the following elements:
Define severity levels: Classify rules into two levels:
Critical(serious violations that should be rejected) andSuggestion(recommended optimizations that can pass but require attention).Provide inspection methods and examples: For each rule, describe how AI should check it and what constitutes a violation, so that AI has clear criteria for making judgments.
The following is an example standard (3 layered dependency rules):
#
Rule
Severity
Inspection method
R1
ADS cannot directly depend on ODS
Critical
SQL references tables prefixed with
ods_in FROM/JOIN clausesR2
Mutual dependencies between ADS tables are prohibited
Critical
SQL references other tables prefixed with
ads_in FROM/JOIN clausesR3
ADS should avoid directly referencing DWD
Suggestion
DWS/DIM layer data should be used preferentially
For a code review standard example, see Appendix: Review standard example.
Proactive review (human-AI collaboration mode)
In this mode, you upload your team's standards and issue review instructions through the AI Assistant web interface. AI Assistant automatically performs the checks. For critical violations, execution is paused and manual confirmation is required.
Step 1: Pull code review requests
Log on to the DataWorks console, and click AI Assistant Service in the left-side navigation pane.
Click the name of the target AI Assistant instance. In the upper-right corner of the instance details page, click Open Conversation to go to the web conversation page.
In the left sidebar, select the Conversation tab and click the + New Task button at the top to create a new conversation.
Enter an instruction in the dialog box. For example:
Show me the code review requests pending my review in workspace 959211
AI Assistant returns a list of pending review requests, indicating that the review targets have been retrieved successfully.
Step 2: Issue a code review instruction
Issue a review instruction to AI Assistant. The instruction must include the following three elements:
Element | Description | Example |
Review standard | Tells AI which standard to check against | The file name of the uploaded team code review standard |
Pass condition | The condition under which AI can automatically approve the request | No critical violations → write the review record and automatically approve the request |
Rejection condition | The condition under which AI must pause and wait for manual confirmation | Critical violation found → Pauses execution, lists violation details, and waits for manual confirmation |
Procedure:
In the dialog box, upload your team's code review standard file (in Markdown format) and the result notification template. You can refer to the following examples:
Review standard example: Review standard example.
Result notification template example: Report notification template.
In the dialog box, enter the review instruction. Example:
Review the code pending my review based on the code review standards. Note the following pass/reject conditions:
• No Critical violations → Write the review record and automatically approve the review
• Critical violations found → Write the review record, then pause execution. List all Critical findings (including rule number, issue description, and fix suggestion), and wait for my item-by-item confirmation before approving or rejecting as instructed.
AI Assistant starts checking code review requests one by one.
Step 3: View review results and confirm manually
After AI Assistant completes the check, it performs the following actions based on the review results:
No Critical violations: AI Assistant automatically approves the review and writes the review record.
Critical violations found: AI Assistant pauses execution, lists all violation details (including rule number, issue description, and fix suggestion), and waits for item-by-item confirmation.
When AI Assistant pauses and waits for confirmation, you can reply with "Confirm approve" or "Confirm reject" based on the suggestions. AI Assistant then performs the corresponding action in DataWorks and writes the review record.
Step 4: Verify review results
Go to DataStudio, select the target workspace, and click Code Review Details in the left-side navigation pane to view the comments and review actions that AI Assistant performed on task code. Compare the AI review results with the expected results to verify the accuracy of AI Assistant's reviews. The following is a verification example:
Review request | Violation level | Expected result | Actual result | AI review record |
Regional transaction ranking analysis | Critical: ADS depends on ODS | Reject, requires manual confirmation | Rejected, manually confirmed | [Pure CR (user-defined rules)] Check rules: Retail e-commerce team internal code review standards (11 rules). Check result: 1 Critical violation found. R1 (Critical): ADS node ads_ec_trd_area_rank directly references 2 ODS tables (ods_trade_order, ods_t_area), violating the "ADS cannot directly depend on ODS" rule. Fix suggestion: Replace ODS tables with DWS/DWD layer tables to ensure the dependency chain follows ODS→DWD/DIM→DWS→ADS. Decision: Rejected. |
Consumer shopping journey analysis daily report | Suggestion: ADS depends on DWD | Passed | Passed | [Pure CR (user-defined rules)] Check rules: Retail e-commerce team internal code review standards (11 rules). Check result: No Critical violations. Suggestion: R3-ADS directly references 3 DWD tables (dwd_ec_log_search_di, dwd_ec_collect_di, dwd_ec_trd_create_ord_di). We recommend optimizing these into DWS layer aggregate tables in the future. Decision: Passed. |
Category transaction dashboard | Critical: ADS depends on ADS | Rejected, pending manual confirmation | Rejected, manually confirmed | [Pure CR (user-defined rules)] Check rules: Retail e-commerce team internal code review standards (11 rules). Check result: 1 Critical violation found. R2 (Critical): ADS node ads_ec_trd_category_dashboard references 2 other ADS tables (ads_ec_itm_hot_rank, ads_ec_trd_gmv_kpi), violating the "ADS tables cannot depend on each other" rule. Additionally, a CROSS JOIN is used, which may cause data explosion. Fix suggestion: Push the dependencies down to the DWS layer and replace the CROSS JOIN with a JOIN that has proper join conditions. Decision: Rejected. |
If the results do not meet your expectations, adjust the standard descriptions or review instructions and run the review again.
Save the review process as a SKILL
After you complete a proactive review and are satisfied with the results, you can save the entire review process as a reusable SKILL. This allows AI Assistant to automatically load your team's standards in subsequent reviews without requiring you to upload standards and write instructions each time.
Step 1: Create a code review SKILL
Enter the following instruction in the AI Assistant dialog box. AI Assistant automatically organizes the review process into a SKILL. Before naming the SKILL, note the following constraints: the name must match the regex ^[a-zA-Z0-9_-]+$ and cannot exceed 64 characters, the description cannot exceed 256 characters, and the SKILL file must be in .zip format.
Summarize the above process into an AI automatic code review SKILL named dataworks-ai-code-review. In future instructions that require code review using custom team code review standards, use this SKILL. Note:
● The file "Retail E-commerce Team Internal Code Review Standards.md" must be maintained as a separate document and used as the knowledge base of the SKILL.
● After creation, verify that the SKILL is packaged and installed successfully.
You can add the following requirements in the instruction to improve the SKILL execution quality:
Do not skip any section of the team standards (all sections must be included in the output).
Do not skip any rule (each rule must be evaluated; mark inapplicable rules with "-").
The report must include basic information, code diff, rule-by-rule check results, and review suggestions.
Step 2: Verify SKILL registration
After the SKILL is created, you can view it on the Skills tab of the AI Assistant instance details page. If it does not appear on the page, ask AI Assistant to register it manually through a conversation:
Register the dataworks-ai-code-review SKILL to the management page.
After successful registration, filter by the Custom type on the Skills tab to find dataworks-ai-code-review.
Step 3: Use the SKILL to perform code review
After the SKILL is saved, you can trigger a review with a simple command without repeatedly uploading standards or writing detailed instructions:
Use the dataworks-ai-code-review SKILL to review the code review requests in workspace 959211.
AI Assistant automatically loads your team's standards, retrieves the review requests, performs item-by-item checks, and outputs a review report.
Scheduled automatic review (fully automatic mode)
If you want AI Assistant to automatically review new code review requests instead of triggering each review manually, you can configure a scheduled review task. In this mode, AI Assistant performs reviews fully automatically: it automatically approves compliant review requests, automatically rejects non-compliant ones, and notifies you of the results through a review report.
This mode depends on a SKILL. You must complete the operations in the "Save the review process as a SKILL" section first.
Step 1: Create a scheduled review task
Log on to the DataWorks console, and click AI Assistant Service in the left-side navigation pane.
Click the Chat button in the Actions column of the target AI Assistant instance.
In the left sidebar, switch to the Scheduled tab (different from the Chat History entry used for proactive review). In an existing conversation, enter the command to create a scheduled task. Example:
Create a code review task that runs every 5 minutes. It should automatically retrieve the code review requests pending my review in workspace 959211 and complete the reviews. Push the review results to the current window using the push template "Report Push Template".
[Notes]
• Use the dataworks-ai-code-review SKILL to automatically complete reviews according to the retail e-commerce team standards without manual confirmation.
[Approval/Rejection conditions] (important!)
• No Critical violations → Write the review record and automatically approve the request.
• Critical violations found → Write the review record and automatically reject the request.
If you have configured the IM channel, you can start scheduled tasks through conversations on the IM side. The bot pushes the review process or results to DingTalk, Lark, or WeChat private chats or group chats, so you can view and handle code review tasks on your mobile device.
After the configuration is complete, AI Assistant automatically scans the workspace for pending review requests at the specified interval, triggers the SKILL to complete the review, and pushes the review report to the current conversation window.
Step 2: Confirm the task and view review results
After the task is created, confirm on the Scheduled Tasks tab in the left sidebar that the review task has been generated. You can view its execution history and review reports. When the first review window arrives, AI Assistant pushes the review report to the current conversation window, indicating that the task is active. The review report contains the following information:
Number of code review requests scanned in this review
Check result for each review request (approved/rejected and the reason)
Actions taken (review record write-back status)
If the scheduled task review results do not meet your expectations, you can modify the scheduled task instructions. For example, you can configure the task to only display findings for Critical violations without writing back, or require manual confirmation before making a decision on Critical violations.
Limits and considerations
dataworks-governance-scenariois an official SKILL. AI Assistant uses this SKILL to obtain code review capabilities such as pulling review requests and performing approve/reject actions. Deleting or disabling this SKILL makes the code review feature unavailable.The quality of AI Assistant reviews depends on the quality of the standard document. We recommend that the standard document includes clear rule numbers, severity levels, inspection methods, and examples. Avoid vague descriptions.
Scheduled review tasks are created and managed through AI Assistant conversation instructions, not through a UI feature.
FAQ
Q: What should I do if AI Assistant review results do not match expectations?
A: Check the following aspects and troubleshoot step by step:
Whether the rule descriptions in the standard document are clear enough, and whether inspection methods and judgment criteria are provided.
Whether the approve/reject conditions in the review instructions are clear, and whether AI Assistant can accurately understand the decision logic.
If AI incorrectly approves a Critical violation, add more specific examples and counterexamples to the standard.
In addition, we recommend that you explicitly emphasize mandatory requirements and prohibited behaviors in the review instructions to prevent AI Assistant from simplifying the review process on its own. You can add the following constraints:
Do not skip any section of the team standards. All check results must be output.
Do not skip any rule. A judgment conclusion must be provided for each rule, and inapplicable rules must be explicitly marked.
Do not approve a request when Critical violations exist. The reject conditions specified in the instructions must be followed.
The review report must include basic information, code changes, rule-by-rule check results, and review suggestions.
Q: How do I modify a scheduled review task that has been created?
A: On the AI Assistant web conversation page, navigate to the conversation in which the task was created, and send a modification instruction to AI Assistant to adjust the review frequency, review scope, or approve/reject conditions.
Q: How do I update the review standards in a saved SKILL?
A: After your team's review standards are updated, re-upload the standard file and have AI Assistant update the knowledge base content in the SKILL. You can do this by sending a conversation instruction such as "Update the review standards of the dataworks-ai-code-review SKILL."
Appendix: Review standard example
# Retail E-commerce Team Internal Code Review Standards
> Applies to workspace 959211 (retail e-commerce business domain: ec). AI code review must check the following rules.
---
## 1. Table creation and naming conventions
> Table naming template (mandatory)
| Layer | Naming template | Example |
|---|---|---|
| ODS | `ods_ec_{business_domain}_{source_table}_{refresh_cycle}` | `ods_ec_trd_trade_order_di` |
| ADS | `ads_ec_{data_domain}_{mart}_{subject}_{granularity}_{stat_cycle}` | `ads_ec_ec360_gmv_kpi_overview` |
**Checkpoints**:
- All table names must contain `_ec_` (retail e-commerce business domain identifier)
- Double underscores `__` are prohibited
## 2. Data warehouse layering dependency conventions
### 2.1 Valid dependency paths
ODS → DWD → DWS → ADS
ODS → DIM → DWD / DWS / ADS
### 2.2 Dependency rules
| # | Rule | Severity | Check method |
|---|------|---------|---------|
| R1 | **ADS must not directly depend on ODS** | Critical | SQL FROM/JOIN references a table prefixed with `ods_` |
| R2 | **ADS tables must not depend on each other** | Critical | SQL FROM/JOIN references another table prefixed with `ads_` |
| R3 | **ADS should avoid directly referencing DWD** | Suggestion | Prefer using DWS/DIM layer data |
## 3. Change rationality conventions
> Check the rationality and completeness of the code change itself, independent of other sections in the standards document.
| # | Rule | Severity | Check method |
|---|------|---------|----------|
| C2 | **Change description is sufficient** | Suggestion | If requestDesc is too brief (e.g., "ceshi", "test", "fix") → flag it |
| C3 | **DDL and DML should not be mixed** | Suggestion | If a single node contains both DDL (CREATE/ALTER/DROP) and DML (INSERT/SELECT), recommend splitting into separate nodes | Appendix: Report push template
# AI Code Review Report · Push Template
---
## Template example
```
⚠️ AI Code Review · Workspace {workspaceId}
{total} pending CRs · {passed} approved · {rejected} rejected · {ruleSetName}
| Node | Version | Violation | Decision |
|------|------|------|------|
| {nodeName} | {version} | {ruleId} · {ruleDesc} ({detail}) | Rejected |
| {nodeName} | {version} | {ruleId} · {ruleDesc} ({detail}) | Approved |
Rejection reasons:
• {nodeName}: {finding}. {suggestion}
Actions taken: Review records for {total} CRs have been written to DataStudio, and all statuses have been updated.
The above content is generated by AI
```
---
## Full example
```
AI Code Review · Workspace 959211
2 pending CRs · 0 approved · 2 rejected · Retail E-commerce Team Standards
| Node | Version | Violation | Decision |
|------|------|------|------|
| Regional Trade Ranking Analysis | v29 | R1 · ADS directly depends on ODS (ods_trade_order, ods_t_area) | Rejected |
| Category Trade Dashboard | v19 | R2 · ADS tables depend on each other (ads_ec_trd_gmv_kpi, ads_ec_itm_hot_rank) | Rejected |
| Consumer Shopping Journey Daily Report | v19 | R3 · ADS references DWD (Suggestion level) | Approved |
Rejection reasons:
• Regional Trade Ranking Analysis: The SQL writes directly to an ADS table but sources data from the ODS layer tables ods_trade_order and ods_t_area, skipping the DWD/DWS layers, violating rule R1 on naming and layering conventions. Recommend adding intermediate layer logic before resubmitting.
• Category Trade Dashboard: The new node JOINs two ADS tables (GMV KPI table + hot-selling product ranking), violating rule R2 that prohibits ADS interdependencies. Recommend moving shared logic down to the DWS layer before resubmitting.
• Consumer Shopping Journey Daily Report: References 3 DWD detail tables. Recommend optimizing to DWS layer aggregate tables in the future.
Actions taken: Review records for 3 CRs have been written to DataStudio, and all statuses have been updated.
The above content is generated by AI
```Appendix: Command reference
Command purpose | Example command |
Pull review requests | Show me the code review requests pending my review in workspace {workspaceId} |
Review against standards (with manual confirmation) | Perform a code review according to "{standard document name}" and output the review results. Approval/rejection criteria: automatically approve if no Critical violations are found; pause and wait for confirmation if Critical violations are found |
Create a SKILL | Summarize the above process into an AI automatic code review SKILL named {SKILL name} |
Register a SKILL to the management page | Register the {SKILL name} SKILL to the management page |
Review using a SKILL | Use the {SKILL name} SKILL to review the code review requests in workspace {workspaceId} for me |
Create a scheduled review task | Create a code review task that runs every {frequency}, automatically pulling pending code review requests in workspace {workspaceId} and completing the review |