NAME

CPAN::Maker::Bootstrapper::Role::LLM - Optional AI-assisted commands and workflows for CPAN::Maker::Bootstrapper

SYNOPSIS

# Install the extension
cpanm CPAN::Maker::Bootstrapper::Role::LLM

# Activate the extension in your CMB project
cd /path/to/your/project
make add-plugin PLUGIN=LLM

# Use the extension
cmb code-review lib/My/Module.pm

DESCRIPTION

This document collects the LLM-specific documentation extracted from CPAN::Maker::Bootstrapper. The commands are provided by the optional LLM extension, not by the core build framework.

LLM Commands

LLM commands use prompt files installed as needed in the .prompts/ directory. You can customize each of these prior to executing a command.

.prompts/change-log.prompt
.prompts/code-review.prompt
.prompts/pod-review.prompt
.prompts/release-notes.prompt

Anthropic API Key

The following commands require LLM::API to be installed and a valid Anthropic API key. Set it in the environment before running any LLM command:

export LLM_API_KEY=$(cat ~/.ssh/anthropic-api-key)

The key is deleted from the environment immediately after being read and is never passed to child processes. See CPAN::Maker::ConfigReader for the llm-api-key-helper option which avoids exposing the key in shell history entirely.

SECURITY NOTE: Never pass your API key on the command line where it would be visible in shell history and process listings.

Commands

ADDITIONAL COMMAND REFERENCES

LLM OPTIONS

THE REVIEW WORKFLOW

CPAN::Maker::Bootstrapper allows you to implement a structured iterative code review workflow built around JSON review files and developer-applied disposition annotations. The workflow converges over several rounds, with each round potentially costing less as noise is suppressed and findings are resolved.

Overview

Each review round consists of three steps:

Dry Run Mode

Before the prompt and code are submitted for review, the script displays estimated token usage and cost. The input token count is obtained from the model's token-counting API using the message that will actually be submitted, so the input count is accurate. The output token count, and therefore the final cost, is an estimate.

To stop before submitting the review, use --dry-run. The command will abort immediately before the message is sent to the LLM.

Dispositions

Each finding in the annotations file must be given one of the dispositions described below before the next review can be submitted. The prompt sent to the LLM is designed around these dispositions. This helps successive reviews converge by carrying forward the developer's decisions from earlier rounds.

Diminishing Returns and When to Stop

Run the annotate command after each review submission to view the findings. Each round tends to surface smaller and more obscure issues as obvious findings are resolved. Despite some fairly aggressive attempts to create prompts that prevent trivial or obscure findings you should stop when you see these signals:

When all findings have dispositions and no new substantive issues appear, the review should be considered complete.

The Release Artifact

When you are satisfied with the review state, finalize it with --finalize-annotations:

cmb annotate --finalize-annotations -a 1:wrong -a 2:reject lib/My/Module.pm

This applies any remaining dispositions, validates that all findings are annotated, reads the version from the VERSION file, and writes the versioned release artifact:

CPAN-Maker-Bootstrapper-1.1.0-REVIEW.json

This file serves as a code review certification for the release - a machine-readable record of every finding examined, every logic confirmation made, and every disposition applied before the version was published. Commit it to the repository alongside your ChangeLog.

All findings marked WRONG are automatically converted to WRONG-RECONSIDER in the release artifact, prompting careful re-examination on the first review of the next version rather than permanent suppression.

Cost Management

Review cost depends on the selected model, source size, prompt profiles, and number of findings. Costs generally decrease over successive rounds as the model spends fewer output tokens re-explaining suppressed findings.

Use your own prompt profiles (--prompt-profile) to suppress entire classes of noise before they reach the annotation file. A well-tuned profile for your application type is the highest-leverage cost reduction available.

See Also

"LLM Commands", "PROMPT PROFILES", CPAN::Maker::ConfigReader

PROMPT PROFILES

Prompt profiles are additive prompt fragments that customize the review behavior for specific application types. They are appended to the base review prompt before submission and are intended to focus the review on relevant concerns while suppressing noise that does not apply to the target context.

NOTE: Prompts count toward your input token count. Be succinct and accurate.

Using Profiles

Pass one or more profiles using the --prompt-profile option:

cmb code-review --prompt-profile cli-tool MyModule.pm

Multiple profiles may be combined:

cmb code-review --prompt-profile cli-tool --prompt-profile security MyModule.pm

Profiles are resolved from the .prompts/ directory in the current project. A profile named cli-tool resolves to .prompts/cli-tool.prompt. Add project-specific prompt profiles to .prompts/ and commit them with your project.

Built-in Profiles

The following profile is installed with the distribution:

Creating Custom Profiles

A profile is a plain text file in .prompts/ containing additional prompt instructions, one per line. Lines beginning with # are treated as comments and stripped before submission. Profile instructions are appended verbatim to the base review prompt. The built-in profiles use one instruction per line, typically prefixed with -.

Example .prompts/security.prompt:

# security profile - add to any review where input handling matters
- Treat all caller-supplied input as untrusted regardless of source.
- Flag any use of eval, system, or exec that incorporates external data.
- Flag missing taint checks on data used in file or system operations.

Additional Profile Ideas

Community contributions of additional profiles are welcome. See https://github.com/rlauer6/CPAN-Maker-Bootstrapper/issues.

SEE ALSO

CPAN::Maker::Bootstrapper, LLM::API