Automatic Plugin Generation from Natural Language Requirements Using AI Agents

    This article describes how AI agents can turn natural language requirements into deployable plugins. It covers the end-to-end workflow, a five-stage architecture, evaluation metrics such as pass@k, security controls, engineering rollout practices, and the boundaries of where automatic generation remains appropriate.

    I. From Handwritten Code to Requirement Descriptions

    Traditional plugin development requires developers to understand interface specifications, write implementations, debug dependencies, and complete deployment. A natural-language-driven generation model moves this workflow earlier: users describe the desired functionality in text, and the system uses an agent to decompose the requirement, generate code, install dependencies, run validation, and finally output a plugin that can be called directly.

    This model lowers the barrier to construction, enabling non-specialist developers to customize simple tools while allowing professional developers to focus on complex logic and architecture design. Output quality depends on the clarity of the requirement description, the model’s reasoning capability, and constraints in the runtime environment, so systematic engineering design is required.

    II. Typical Technical Architecture

    A production-ready system usually includes the following five stages.

    1. Requirement parsing: split natural language into inputs, outputs, trigger conditions, and exception scenarios.
    2. Task planning: decompose the requirement into verifiable subtasks, such as data reading, transformation, and result writing.
    3. Code generation: generate source code and metadata according to a unified plugin specification, including function signatures, parameter types, and dependency lists.
    4. Sandbox execution: install dependencies and run unit tests in an isolated environment; on failure, return error information to the generation module for correction.
    5. Registration and publishing: after validation, write to the plugin repository and record the version number, code hash, and prompt content used during generation.

    The following pseudocode illustrates the process only:

    1. def build_plugin(requirement: str, max_retries: int = 3) -> Plugin:
    2. spec = parse_requirement(requirement) # Parse inputs, outputs, and boundary conditions
    3. tests = generate_tests(spec) # Generate tests before implementation
    4. for attempt in range(max_retries):
    5. code = generate_code(spec)
    6. result = run_in_sandbox(code, tests)
    7. if result.passed:
    8. return register(code, spec, version=attempt)
    9. spec = refine_spec(spec, result.errors)
    10. raise BuildError("Maximum retries exceeded; manual intervention required")

    Generating tests first and then generating the implementation is the most critical design in this workflow. Tests provide machine-checkable acceptance criteria and avoid subjective judgment by the model on its own output.

    III. Evaluating Generation Quality

    Evaluating such systems requires quantitative metrics; demo results alone are not enough.

    Pass@1 refers to the proportion of single-generation results that pass all tests. For a task sampled n times, with c passes, pass@k can be computed with an unbiased estimator:

    pass@k = 1 − C(n−c, k) / C(n, k)

    When k = 1, the formula reduces to c / n. Evaluation should use a fixed test set and disclose the coverage of test cases; otherwise numbers from different systems cannot be compared directly.

    In addition to pass rate, the following metrics should be recorded:

    • Average cost per task: including model invocation cost and sandbox resource consumption.
    • Average number of retries: reflecting how well the requirement description matches generation quality.
    • End-to-end latency: time from requirement submission to plugin availability.
    • Manual modification ratio: proportion of generated code lines modified by humans, used to measure practical usability.

    These metrics should be reported by task difficulty. Simple format conversion and complex multi-step data processing have very different meanings.

    IV. Security and Governance

    Automatically generating and executing code means running programs whose behavior cannot be fully known in advance, so security boundaries must be defined at the design stage.

    • Sandbox isolation: restrict file system, network, and process permissions; block external connections by default.
    • Dependency allowlist: only allow installation of reviewed dependency packages and lock version numbers.
    • Least privilege: grant plugins only the access scope required by their declared permissions at runtime.
    • Static scanning: check for dangerous calls before registration, such as arbitrary command execution and sensitive path reads/writes.
    • Audit logs: retain the original requirement text, generated code, execution results, and operator for traceability.

    User input should also be treated as untrusted data. If requirement text contains content that attempts to rewrite system instructions, the parsing stage should identify it and refuse execution.

    V. Engineering Deployment Recommendations

    1. Start with low-risk scenarios, such as data format conversion, text cleaning, and report summarization. After confirming the results, expand to scenarios that write business data.
    2. Bring generated results under version control, retain the full history of each plugin, and roll back to the previous stable version if problems occur.
    3. Set manual confirmation points for plugins involving funds, permissions, or production data; do not publish them without review.
    4. Build a regression test set. Rerun all tests whenever the model version is changed or prompt content is adjusted.

    VI. Applicability Boundaries

    This model is suitable for small tools with clear inputs and outputs and well-defined boundaries. For modules that require deep understanding of existing system architecture, complex state management, or high-concurrency requirements, generated code usually still needs refactoring by senior developers. Teams should judge whether to adopt it based on the nature of the task. Automatic generation can improve efficiency, but design and code review remain the developer’s responsibility.