A code generation system and method based on preset code scanning rules

By combining large language models and code scanning rules in the integrated development and operations platform, end-to-end automated generation of high-quality code from requirements is achieved, solving the problem of the separation between code generation and scanning detection, improving the quality and efficiency of generated code, and reducing the waste of manual review and computing resources.

CN122363708APending Publication Date: 2026-07-10BEIJING SIMPLE POINT TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
BEIJING SIMPLE POINT TECH CO LTD
Filing Date
2026-06-01
Publication Date
2026-07-10

AI Technical Summary

Technical Problem

In existing technologies, AI code generation tools do not make full use of the enterprise's existing code scanning rules data, resulting in generated code that does not meet the enterprise's code quality standards. Furthermore, the generation and scanning detection processes are disconnected, leading to low efficiency and increased costs for manual review and waste of computing resources.

Method used

In the integrated development and operations platform, the rule data of the large language model and code scanning module are combined to guide code generation through structured prompt word templates, realizing an end-to-end automated process from requirements to high-quality code, including requirement acquisition, rule extraction, code generation and verification, and using the rule verification module for closed-loop feedback and automatic correction.

Benefits of technology

The generated code directly conforms to enterprise code standards, reducing the number of iterations for manual review and scanning, improving development efficiency, saving computing resources, and realizing an efficient and automated process from requirements to code.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122363708A_ABST
    Figure CN122363708A_ABST
Patent Text Reader

Abstract

This invention discloses a code generation system and method based on pre-set code scanning rules, including a requirement acquisition module, a rule extraction module, a prompt word construction module, a code generation module, a rule verification module, and a result output module. The requirement acquisition module, rule extraction module, prompt word construction module, code generation module, rule verification module, and result output module interact with each other through a standardized interface. This invention deeply integrates the rule data accumulated by enterprises in the code scanning module with artificial intelligence code generation capabilities, enabling enterprises to automatically apply their existing code quality assurance experience to the generation process of new code, realizing the value-added utilization of data assets. Through the closed-loop feedback mechanism of the rule verification module, this invention can automatically construct correction instructions and regenerate when the code fails the scanning detection, reducing manual intervention and improving the level of automation.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the interdisciplinary fields of software engineering and artificial intelligence, specifically a code generation system and method based on pre-defined code scanning rules. Background Technology

[0002] In the field of software engineering, code quality assurance has always been a crucial part of the software development process. Traditional code quality assurance primarily relies on manual code review and static code analysis tools. Static code analysis tools use predefined scanning rules to automatically inspect source code, identifying issues such as coding style violations, potential security vulnerabilities, performance defects, and memory leaks. Over the years, enterprises have accumulated a large number of code scanning rules within their DevOps platforms. These rules reflect the enterprise's coding standards and best practices.

[0003] Meanwhile, artificial intelligence technology, especially large language model (LLM) technology, has made groundbreaking progress in recent years. Large language models possess powerful natural language understanding and code generation capabilities, automatically generating software code based on requirements descriptions. This capability has spurred the rapid development of intelligent integrated development environments (AI-IDEs), significantly improving code generation efficiency.

[0004] However, current AI code generation technology is disconnected from existing enterprise code quality assurance systems. Large language models lack awareness of enterprise-specific coding standards and scanning rules when generating code, resulting in code that, while functionally correct, often fails to meet enterprise coding standards and requires multiple rounds of modification to pass code scanning checks. Deeply integrating existing enterprise code scanning rules with the code generation capabilities of large language models to achieve one-time generation of high-quality, enterprise-compliant code has become a crucial direction for current technological development.

[0005] In recent years, DevOps platforms have become the mainstream tool platform for software development teams in the field of software engineering. DevOps platforms provide basic tool support for the entire software development lifecycle, including requirements management, code hosting, code scanning, automated pipelines, testing, and deployment capabilities, which greatly improves the digital collaboration efficiency and management capabilities of software development teams.

[0006] Meanwhile, with the development of artificial intelligence (AI) technology, the ability to efficiently generate code directly based on requirements through large language modeling (LLM) capabilities has become the mainstream technology in the industry, and various intelligent integrated development environments (AI-IDEs) both domestically and internationally provide related functions. For example, products from major domestic technology companies such as Tencent's CodeBuddy, ByteDance's Trae, and Baidu's Comate, as well as international companies such as ClaudeCode and CodeX, all possess related functions.

[0007] In terms of code quality assurance, mainstream DevOps platforms typically integrate code scanning modules. These modules contain a rich set of scanning rules covering multiple dimensions, including coding standard checks (such as naming conventions, code formatting, and comment requirements), security vulnerability detection (such as SQL injection, cross-site scripting attacks, and hard-coded sensitive information), code defect identification (such as null pointer references, memory leaks, unreleased resources, and concurrency security issues), and performance optimization suggestions (such as inefficient algorithms, redundant computations, and inappropriate database queries). These rules have been validated through long-term engineering practice and are a crucial asset for enterprise software quality assurance.

[0008] However, in existing technologies, AI code generation and code scanning are two independent processes. Developers typically use AI tools to generate code first, then submit the generated code to a code scanning module for detection. If problems are found, they either manually modify the code or request the AI ​​to regenerate it. This iterative "generate-scan-modify" process is inefficient and increases development costs.

[0009] Existing artificial intelligence (AI) technologies, when generating software code based on requirements using Large Language Models (LLMs), suffer from the following main problems: The company's existing code scanning rule data was not fully utilized. Existing AI code generation tools do not take into account the various rules (including coding standards, security vulnerability detection rules, code defect identification rules, etc.) accumulated by enterprises in the code scanning module of DevOps platforms as constraints for code generation, resulting in generated code that does not meet the enterprise's code quality standards.

[0010] The code generation and code scanning processes are disconnected. In existing technologies, code generation and code scanning and detection are two independent sequential steps. Code needs to be generated first, then scanned and detected, and then modified after problems are found, forming multiple iterative cycles, resulting in low development efficiency.

[0011] High cost of manual review Because the code generated by large language models lacks awareness of enterprise coding standards, developers need to spend a lot of time manually reviewing and modifying the generated code, which offsets the efficiency gains brought by AI code generation.

[0012] Waste of computing resources After the large language model generates code that does not conform to the rules, it needs to be scanned and detected again by the code scanning module. If the scan finds problems, it may be necessary to call the large language model again to correct the code, resulting in the repeated consumption of computing resources.

[0013] End-to-end automation from requirements to code has not been implemented. In existing technologies, manual intervention is usually required for steps such as obtaining requirement information from the requirement management module, calling the large language model to generate code, and performing rule verification on the generated code. There is a lack of a one-stop automated process from requirements to high-quality code. Summary of the Invention

[0014] The purpose of this invention is to leverage the capabilities of current DevOps platforms by combining them with Large Language Model (LLM) capabilities. This involves integrating the large amount of rule data accumulated in the code scanning module of the DevOps platform with the LLM to directly generate high-quality code that meets the rules of the enterprise's code scanning module based on the requirements in the DevOps platform's requirement management module. This reduces the time and computational costs associated with manual review and subsequent re-scanning and testing of the code generated by the LLM by the code scanning module.

[0015] The key technical points and protection points of this invention are as follows: 1. Deeply integrate the large amount of rule data accumulated in the code scanning module of the DevOps platform with the Large Language Model (LLM). In the code generation stage, the scanning rules are used as generation constraints, enabling the Large Language Model to directly generate high-quality code that conforms to enterprise code standards.

[0016] 2. The rule extraction module can automatically filter, classify, sort, and intelligently trim scanning rules based on programming language and technology stack, adapting to the context window limitations of large language models to ensure the effective transmission of rule information.

[0017] 3. The prompt word construction module adopts a structured prompt word template, which systematically assembles requirement information and rule constraints. It includes four parts: system instruction area, rule constraint area, requirement description area, and output constraint area, so as to achieve precise guidance for the generation behavior of large language models.

[0018] 4. The rule verification module implements a closed-loop feedback mechanism. When the code fails the scanning detection, the violation information is automatically fed back to the prompt word construction module, and the code is regenerated after adding correction instructions, which has the ability to automatically iterate and correct.

[0019] 5. The system implements an end-to-end automated process from the requirement management module to obtain requirements, extract code scanning rules, construct prompt words, call the large language model to generate code, rule verification and code output. Each module interacts with data through standardized interfaces.

[0020] 6. The rule verification module has a maximum iteration threshold control mechanism. Once the threshold is exceeded, the current best result along with the remaining violation information will be output and marked as requiring manual review, thus balancing automation efficiency and quality assurance.

[0021] To achieve the above objectives, the present invention provides the following technical solution: A code generation system and method based on pre-defined code scanning rules includes a requirement acquisition module, a rule extraction module, a prompt word construction module, a code generation module, a rule verification module, and a result output module. The requirement acquisition module, rule extraction module, prompt word construction module, code generation module, rule verification module, and result output module interact with each other through standardized interfaces to form a complete processing flow from requirement input to high-quality code output. The requirement acquisition module, rule extraction module, rule verification module, and result output module are respectively connected to a DevOps platform.

[0022] As a further aspect of the present invention: the DevOps platform includes a requirements management module, a code scanning module, a code scanning engine, and a code hosting module.

[0023] As a further aspect of the present invention: the requirement acquisition module is connected to the requirement management module and is responsible for acquiring software requirement information to be implemented. The requirement acquisition module supports reading structured data such as the title, detailed description, acceptance criteria, and associated technology stack information of the requirements from the requirement management module.

[0024] As a further aspect of the present invention: the rule extraction module is connected to the code scanning module and is responsible for extracting scanning rules related to the current code generation task from the rule base of the code scanning module.

[0025] As a further aspect of the present invention: the prompt word construction module assembles the demand information provided by the demand acquisition module and the rule data provided by the rule extraction module according to the predefined prompt word template to generate structured prompt words.

[0026] As a further aspect of the present invention: the prompt word structure includes a system instruction area, a rule constraint area, a requirement description area, and an output constraint area. The system instruction area is used to define the role of the large language model as a professional software development engineer, requiring it to strictly follow the given code scanning rules to generate code. The rule constraint area embeds the rule list output by the rule extraction module into the prompt word, presenting the name, description, and example of each rule in a structured format. The requirement description area is used to embed the standardized requirement information output by the requirement acquisition module into the prompt word, clarifying the functional requirements, input and output specifications, and technical constraints of the code. The output constraint area is used to specify the output format requirements of the code, including code structure, comment specifications, naming conventions, etc., and requires the large language model to explain how it satisfies each scanning rule when generating code.

[0027] As a further aspect of the present invention: the code generation module sends the structured prompt words generated by the prompt word construction module to the large language model interface, calls the large language model to generate code, and the code generation module supports configuring different large language model backends, including but not limited to general large language models and code-specific large language models. The code generation module receives the code text returned by the large language model, performs formatting processing, and then passes it to the rule verification module.

[0028] As a further aspect of the present invention: the rule verification module performs a secondary verification on the code output by the code generation module to ensure that the generated code does indeed conform to the preset code scanning rules.

[0029] As a further aspect of the present invention: the result output module is used to output the verified code and related metadata (including the list of rules followed, verification result report, number of iterations and corrections, etc.) to the code hosting module of the DevOps platform, supporting the automatic creation of code branches and submission of merge requests.

[0030] The code generation method based on pre-defined code scanning rules has the following steps: Step 1: The requirements elicitation module reads structured data such as the title, detailed description, acceptance criteria, and associated technology stack information (such as programming language and framework version) of the requirements from the requirements management module of the DevOps platform. Step 2: The requirement acquisition module further standardizes the original requirement information and then passes it to the prompt word construction module; Step 3: The rule extraction module further extracts scanning rules related to the current code generation task from the rule base of the code scanning module and passes them to the prompt word construction module; Step 4: The prompt word construction module assembles the requirement information provided by the requirement acquisition module and the rule data provided by the rule extraction module according to the predefined prompt word template to generate structured prompt words; Step 5: The code generation module sends the structured prompts generated by the prompt word construction module to the large language model interface, and calls the large language model to generate code. The code generation module further receives the code text returned by the large language model, performs formatting processing, and then passes it to the rule validation module. Step Six: The rule verification module further verifies the code output by the code generation module to ensure that the generated code does indeed conform to the preset code scanning rules; Step 7: Finally, the results output module will output the verified code and related metadata (including the list of rules followed, verification result report, number of iterations and corrections, etc.) to the code hosting module, supporting the automatic creation of code branches and the submission of merge requests.

[0031] Compared with the prior art, the beneficial effects of the present invention are: Improve code generation quality; This invention uses the large amount of rule data accumulated in the enterprise code scanning module as the generation constraint of the large language model, so that the large language model considers coding standards, security requirements and defect avoidance when generating code, thereby improving the quality of generated code from the source and reducing subsequent modifications and rework.

[0032] Reduce the cost of manual review.

[0033] The code generated by this invention pre-complies with enterprise code scanning rules, which greatly reduces the workload of developers in manually reviewing and modifying the generated code, allowing developers to devote more energy to high-value work such as business logic design and architecture optimization.

[0034] Save computing resources.

[0035] This invention incorporates rule constraints during the code generation stage, reducing the number of iterations required for scanning and detecting problems after code generation and re-calling the large language model to correct the code. This effectively reduces the number of calls to the large language model and the number of scans by the code scanning module, saving computing power costs.

[0036] Achieve end-to-end automation from requirements to code.

[0037] This invention system integrates three stages: requirements management, code scanning rules, and large language model code generation, realizing a one-stop automated process from requirements acquisition to high-quality code output, significantly improving software development efficiency.

[0038] Fully leverage the value of existing enterprise data assets.

[0039] This invention deeply integrates the rule data accumulated by enterprises in the code scanning module with the artificial intelligence code generation capability, enabling enterprises to automatically apply their existing code quality assurance experience to the generation process of new code, thereby realizing the value-added utilization of data assets.

[0040] It has automatic correction capabilities.

[0041] This invention utilizes a closed-loop feedback mechanism in the rule verification module to automatically construct and regenerate correction instructions when code fails the scanning detection, reducing manual intervention and further improving the level of automation. Attached Figure Description

[0042] Figure 1 This is a schematic diagram of the system architecture of a code generation system based on pre-defined code scanning rules.

[0043] Figure 2 This is a flowchart illustrating a code generation method based on pre-defined code scanning rules. Detailed Implementation

[0044] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0045] Please see Figures 1-2 In this embodiment of the invention, a code generation system based on preset code scanning rules includes a requirement acquisition module, a rule extraction module, a prompt word construction module, a code generation module, a rule verification module, and a result output module. The requirement acquisition module, rule extraction module, prompt word construction module, code generation module, rule verification module, and result output module interact with each other through a standardized interface to form a complete processing flow from requirement input to high-quality code output. The requirement acquisition module, rule extraction module, rule verification module, and result output module are respectively connected to the DevOps platform, which includes a requirement management module, a code scanning module, a code scanning engine, and a code hosting module. The requirement acquisition module is connected to the requirement management module and is responsible for acquiring software requirement information to be implemented. The requirement acquisition module supports reading structured data from the requirement management module, such as the requirement title, detailed description, acceptance criteria, and associated technology stack information (e.g., programming language, framework version). After standardizing the raw requirement information, the requirement acquisition module passes it to the prompt word construction module. The rule extraction module is connected to the code scanning module and is responsible for extracting scanning rules related to the current code generation task from the rule base of the code scanning module. Its specific processing flow is as follows: Step 1: Based on the programming language and technology stack specified in the requirements information, select the corresponding set of scanning rules from the rule base; Step 2: Categorize and organize the rules according to their category (coding standard, security vulnerability, code defect, performance optimization) and severity level (critical, major, minor, warning); Step 3: Convert each rule into a natural language description format, including the rule name, rule description, example code for violations, and example code for compliance (if example code is included in the rule base); Step 4: Prioritize the rules, placing those with higher severity levels first to ensure that the large language model focuses on key rules first. Step 5: Based on the context window limitation of the large language model, intelligently prune the rule set, and control the total length of the rule text to not exceed the preset threshold of the context window while retaining high-priority rules; The prompt word construction module assembles the requirement information provided by the requirement acquisition module and the rule data provided by the rule extraction module according to the predefined prompt word template to generate structured prompt words. The prompt text is structured into a system instruction area, a rule constraint area, a requirement description area, and an output constraint area. The system instruction area defines the large language model as a professional software development engineer, requiring it to strictly adhere to given code scanning rules when generating code. The rule constraint area embeds the rule list output by the rule extraction module into the prompt text, presenting the name, description, and example of each rule in a structured format. The requirement description area embeds standardized requirement information output by the requirement acquisition module into the prompt text, clarifying the code's functional requirements, input / output specifications, and technical constraints. The output constraint area specifies the code's output format requirements, including code structure, commenting conventions, and naming rules, requiring the large language model to explain how each code satisfies the various scanning rules during code generation. The code generation module sends the structured prompts generated by the prompt word construction module to the large language model interface, calls the large language model to generate code, and supports the configuration of different large language model backends, including but not limited to general large language models and code-specific large language models. The code generation module receives the code text returned by the large language model, performs formatting processing, and then passes it to the rule verification module. The rule verification module performs a secondary verification on the code output by the code generation module to ensure that the generated code does indeed conform to the preset code scanning rules. The specific verification process is as follows: Step 1: Call the scanning interface of the code scanning module of the DevOps platform to perform automated scanning on the generated code; Step 2: Collect the scan results and determine if there are any rule violations; Step 3: If no violations are found in the scan results or only low-priority alerts are present, the code is deemed to have passed the verification and is passed to the result output module. Step 4: If there are serious or major violations in the scan results, the violation information and the original code will be fed back to the prompt word construction module. The prompt word construction module will then add violation correction instructions to the original prompt word and call the code generation module again to correct the code. Step 5: Set the maximum number of iterations threshold for the above correction loop (default is 3 times). If the threshold is exceeded, output the current best result along with the remaining violation information and mark it as requiring manual review. The result output module is used to output the verified code and related metadata (including the list of rules followed, verification result report, number of iterations and corrections, etc.) to the code hosting module of the DevOps platform, and supports automatic creation of code branches and submission of merge requests.

[0046] The code generation method based on pre-defined code scanning rules has the following steps: Step 1: The requirements elicitation module reads structured data such as the title, detailed description, acceptance criteria, and associated technology stack information (such as programming language and framework version) of the requirements from the requirements management module of the DevOps platform. Step 2: The requirement acquisition module further standardizes the original requirement information and then passes it to the prompt word construction module; Step 3: The rule extraction module further extracts scanning rules related to the current code generation task from the rule base of the code scanning module and passes them to the prompt word construction module; Step 4: The prompt word construction module assembles the requirement information provided by the requirement acquisition module and the rule data provided by the rule extraction module according to the predefined prompt word template to generate structured prompt words; Step 5: The code generation module sends the structured prompts generated by the prompt word construction module to the large language model interface, and calls the large language model to generate code. The code generation module further receives the code text returned by the large language model, performs formatting processing, and then passes it to the rule validation module. Step Six: The rule verification module further verifies the code output by the code generation module to ensure that the generated code does indeed conform to the preset code scanning rules; Step 7: Finally, the results output module will output the verified code and related metadata (including the list of rules followed, verification result report, number of iterations and corrections, etc.) to the code hosting module, supporting the automatic creation of code branches and the submission of merge requests.

[0047] This embodiment uses a common Java Web application development scenario in enterprises as an example to illustrate the specific implementation of this system.

[0048] Step 1: Developers create a requirement in the requirements management module of the DevOps platform, titled "Implement User Login Interface". The detailed description includes information such as the interface's input parameters (username, password), output format (JSON format login token), and technology stack requirements (Java, Spring Boot framework).

[0049] Step 2: The requirement acquisition module reads the structured data of the requirement through the platform interface and identifies the programming language as Java and the framework as Spring Boot.

[0050] Step 3: The rule extraction module extracts relevant rules from the code scanning module's rule base based on the Java language. Examples include: (a) Security rule – Password parameters must not be stored in plaintext and must be processed using a cryptographic hash algorithm; (b) Security rule – To prevent SQL injection, database queries must use parameterized queries or prepared statements; (c) Coding standard rule – Method naming uses camelCase; (d) Defect rule – Resource objects (such as database connections) must be properly closed after use; (e) Performance rule – Avoid creating duplicate objects in loops. A total of 47 relevant rules were extracted, and after priority sorting and intelligent pruning, 32 core rules were retained.

[0051] Step 4: The prompt word construction module assembles the requirement information and 32 rules into structured prompt words according to the template and sends them to the code generation module.

[0052] Step 5: The code generation module calls the large language model to generate Java code for the user login interface, including code for the controller layer, service layer, and data access layer (DAO).

[0053] Step 6: The rule validation module calls the code scanning module to scan the generated code. The first scan finds two major violations (one instance of failure to validate user input length, and another instance of inadequate exception handling). The system feeds back the violation information to the prompt word construction module, adds correction instructions, and regenerates the code. The second scan results in zero violations, and the code passes validation.

[0054] Step 7: The results output module will automatically submit the validated code to the code hosting module, create a feature branch, and initiate a merge request.

[0055] This example uses the generation of a Python data processing script. The developer describes in the requirements management module as "writing a Python script to read sales data from a CSV file and generate a statistical report." The rule extraction module extracts scanning rules related to the Python language, including: (a) security rules—file path parameters must be validated to prevent path traversal attacks; (b) coding style rules—following the PEP 8 coding style; (c) defect rules—file operations must use a context manager (with statement) to ensure resource release; (d) performance rules—large data volume processing should use a chunked reading method. The prompt word construction module assembles the above rules with the requirements information and calls the large language model to generate code. The rule validation module passes all rule checks in one scan, and the code is directly output.

[0056] This example illustrates the application of the system in a multi-language project. The requirement is described as "implementing a front-end and back-end separated user registration function, with the front-end using TypeScript and React frameworks, and the back-end using Go language." The rule extraction module extracts TypeScript rule sets and Go language rule sets from the rule base respectively. The prompt word construction module constructs independent prompt words for the front-end code and back-end code respectively, each containing scanning rule constraints for the corresponding language. The code generation module calls the large language model to generate front-end component code and back-end interface code respectively. The rule validation module performs scanning rule checks on the two parts of the code for the corresponding language to ensure that both the front-end code and the back-end code meet their respective rule requirements.

[0057] Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art can still modify the technical solutions described in the foregoing embodiments or make equivalent substitutions for some of the technical features. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.

Claims

1. A code generation system based on pre-defined code scanning rules, comprising a requirement acquisition module, a rule extraction module, a prompt word construction module, a code generation module, a rule verification module, and a result output module, characterized in that: The requirement acquisition module, rule extraction module, prompt word construction module, code generation module, rule verification module, and result output module interact with each other through standardized interfaces to form a complete processing flow from requirement input to high-quality code output. The requirement acquisition module, rule extraction module, rule verification module, and result output module are respectively connected to the DevOps platform.

2. The code generation system based on preset code scanning rules according to claim 1, characterized in that: The DevOps platform includes a requirements management module, a code scanning module, a code scanning engine, and a code hosting module.

3. The code generation system based on preset code scanning rules according to claim 1, characterized in that: The requirement acquisition module is connected to the requirement management module and is responsible for acquiring software requirement information to be implemented. The requirement acquisition module supports reading structured data such as the title, detailed description, acceptance criteria, and associated technology stack information of the requirements from the requirement management module.

4. The code generation system based on preset code scanning rules according to claim 1, characterized in that: The rule extraction module is connected to the code scanning module and is responsible for extracting scanning rules related to the current code generation task from the rule base of the code scanning module.

5. The code generation system based on preset code scanning rules according to claim 1, characterized in that: The prompt word construction module assembles the requirement information provided by the requirement acquisition module and the rule data provided by the rule extraction module according to the predefined prompt word template to generate structured prompt words.

6. The code generation system based on preset code scanning rules according to claim 1, characterized in that: The prompt word structure includes a system instruction area, a rule constraint area, a requirement description area, and an output constraint area. The system instruction area is used to define the role of the large language model as a professional software development engineer, requiring it to strictly follow the given code scanning rules to generate code. The rule constraint area embeds the rule list output by the rule extraction module into the prompt word, presenting the name, description, and example of each rule in a structured format. The requirement description area is used to embed the standardized requirement information output by the requirement acquisition module into the prompt word, clarifying the functional requirements, input and output specifications, and technical constraints of the code. The output constraint area is used to specify the output format requirements of the code, including code structure, commenting specifications, and naming conventions, and requires the large language model to explain how it satisfies each scanning rule when generating code.

7. The code generation system based on preset code scanning rules according to claim 1, characterized in that: The code generation module sends the structured prompts generated by the prompt word construction module to the large language model interface, calls the large language model to generate code, and supports the configuration of different large language model backends, including but not limited to general large language models and code-specific large language models. The code generation module receives the code text returned by the large language model, performs formatting processing, and then passes it to the rule verification module.

8. The code generation system based on preset code scanning rules according to claim 1, characterized in that: The rule verification module performs a secondary verification on the code output by the code generation module to ensure that the generated code does indeed conform to the preset code scanning rules.

9. The code generation system based on preset code scanning rules according to claim 1, characterized in that: The result output module is used to output the verified code and related metadata to the code hosting module of the DevOps platform, and supports automatic creation of code branches and submission of merge requests.

10. The code generation method based on preset code scanning rules according to claim 1, characterized in that: The method and steps are as follows: Step 1: The requirements elicitation module reads the structured data of the requirements title, detailed description, acceptance criteria, and associated technology stack information from the requirements management module of the DevOps platform. Step 2: The requirement acquisition module further standardizes the original requirement information and then passes it to the prompt word construction module; Step 3: The rule extraction module further extracts scanning rules related to the current code generation task from the rule base of the code scanning module and passes them to the prompt word construction module; Step 4: The prompt word construction module assembles the requirement information provided by the requirement acquisition module and the rule data provided by the rule extraction module according to the predefined prompt word template to generate structured prompt words; Step 5: The code generation module sends the structured prompts generated by the prompt word construction module to the large language model interface, and calls the large language model to generate code. The code generation module further receives the code text returned by the large language model, performs formatting processing, and then passes it to the rule validation module. Step Six: The rule verification module further verifies the code output by the code generation module to ensure that the generated code does indeed conform to the preset code scanning rules; Step 7: Finally, the results output module will output the verified code and related metadata to the code hosting module, supporting the automatic creation of code branches and the submission of merge requests.