CPAN::Maker::Bootstrapper::Role::LLM - Optional AI-assisted commands and workflows for CPAN::Maker::Bootstrapper
# 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
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 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
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.
code-review
Submits a Perl module or script to the LLM for a code review. POD is automatically stripped before submission so token costs reflect code only. The review is written as a JSON file to the current directory.
cmb code-review [options] lib/My/Module.pm
The review file is named:
<module>-review-<timestamp>.code
A token usage summary is printed to stderr after the review completes.
If a review has been completed at least once the annotated review file
is automatically sent with your code to re-focus the review. You must
annotate the review file before resubmitting by running the
annotate command and marking each finding with a valid
disposition. See "THE REVIEW WORKFLOW" for details.
Options specific to code-review:
--prompt|-p PATH path to a custom review prompt file
--prompt-profile|-P NAME additive prompt profile (repeatable)
--context|-C PATH context file to submit alongside the review (repeatable)
Note: The prompt profile list and the context file list are written to the review output file. On subsequent runs these will be read from the review. You do not need to provide them unless you want to update their values.
annotate
Applies disposition tags to findings in the latest review file and
displays the current annotation state. Must be run from a project
directory (one containing .includes/).
cmb annotate [options] lib/My/Module.pm
Without options, displays the current annotation state of the latest
review file. With -a options, applies the specified dispositions
before displaying.
cmb annotate lib/My/Module.pm
cmb annotate -a 1:wrong -a 2:reject lib/My/Module.pm
Options:
--annotate|-a N:DISPOSITION apply disposition to finding N (repeatable)
--auto-annotate|-A annotate and immediately submit the next review
--finalize-annotations|-F create versioned release artifact
Valid dispositions are accept, reject, wrong,
wrong-reconsider, defer, and confirmed (case
insensitive). See "THE REVIEW WORKFLOW" for a description of each.
pod-finding
cmb pod-finding lib/CPAN/Maker/Bootstrapper.pm
Run this after a pod-review command to display a table of findings.
pod-review
Submits a Perl module or script to the LLM for a documentation review.
The full file including code is submitted so the LLM can check
consistency between implementation and documentation. If no POD
exists, the LLM generates complete POD documentation suitable for
placement after __END__.
cmb pod-review lib/My/Module.pm
The review file is named:
<module>-review-<timestamp>.pod
release-notes
Generates release notes for a given version using the LLM. Requires
the release artifacts produced by make release-notes:
release-<version>.diffs
release-<version>.lst
release-<version>.status
release-<version>.tar.gz
cmb release-notes <version>
The generated release notes are written to
release-notes-<version>.md. Binary files are automatically
excluded. Use --max-diff-files to cap token consumption on large
distributions (default: 50, 0 = unlimited).
code-finding
Generates a table with the complete details of a finding.
cmb code-finding lib/My/Module.pm 1
show-defaults
Prints the resolved default option values to STDOUT after applying configuration-file values and runtime defaults.
update-annotations
cmb update-annotations file
Applies human-curated annotations to the most recent code review for
file. On first run it generates an .annotate file alongside the
review for you to edit; re-run it to apply your edited annotations back
into the review. Pairs with code-review/annotate in the review
workflow.
change-log
Generates a draft ChangeLog entry for a release using the LLM.
The command uses the release artifacts produced by
make release-notes, including the Git status, diffs,
file inventory, and distribution tarball.
cmb change-log
cmb change-log <version>
The generated entry is written to ChangeLog-VERSION.tmp
in the current directory. An existing output file is not
overwritten.
The command uses .prompts/change-log.prompt, which may be
customized to follow the project's established ChangeLog format.
The project's ChangeLog is not modified. Review the generated
entry and incorporate it manually.
See "THE PROJECT MAKEFILE" for the make change-log target.
--annotate|-a N:DISPOSITION
--auto-annotate|-A
--context|-C PATH
One or more files to submit with your code review file that provide additional context for the LLM during the review.
--finalize-annotations|-F
--max-diff-files LIMIT
The maximum number of changed files included in the release artifact
that may be uploaded to the LLM when generating release notes. Set to
0 for no limit.
default: 50
--max-tokens|-t TOKENS
Maximum number of tokens the LLM may return in a single response. Higher values reduce the risk of truncated reviews on large files.
default: 4096 (set by LLM::API)
--model|-M MODEL
Specifies the model id to use for LLM commands.
For pod-review the default model is claude-haiku-4-5-20251001.
For code-review the default model is claude-sonnet-4-6.
The Haiku model tends to be better at summarizing documentation and avoiding unnecessary analysis around edge cases that contribute to noise.
Caution: Both models try hard to find issues to the point that you will almost never get a clean run when asking for a POD review. When your POD is complete, accurate and usable it's good enough. Avoid shaving the yak!
--prompt|-p PATH
Path to a text file that will be used to prompt the LLM for a code or pod review.
defaults:
pod => .prompts/pod-review.prompt
code => .prompts/code-review.prompt
--prompt-profile|-P NAME
The name of a prompt profile located in the .prompts directory. One
or more profile names may be specified. You need only provide the name
(e.g. cli-tool).
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.
Each review round consists of three steps:
Run a review
cmb code-review --prompt-profile cli-tool lib/My/Module.pm
The review is written to a timestamped .code file containing a JSON
object with findings, confirmations, and deferred arrays.
An annotation is how you mark a finding with a disposition. The dispositions are used by the LLM during the next review. See "Dispositions".
cmb annotate lib/My/Module.pm
This displays the current annotation state. Apply dispositions with
-a options:
cmb annotate -a 1:accept -a 2:wrong -a 3:reject -a 4:defer lib/My/Module.pm
You can annotate incrementally across multiple invocations. Each call shows the updated state so you always know what remains.
Alternatively, use update-annotations to maintain dispositions in an
annotation file rather than on the command line:
cmb update-annotations lib/My/Module.pm
The first invocation creates an .annotate file for editing. Run the
command again after editing the file to apply those dispositions to the
review.
Once all findings are annotated and code updated if necessary, run the next review. The bootstrapper automatically finds and submits the latest annotated review file with your updated code:
cmb code-review lib/My/Module.pm
Alternatively, use --auto-annotate|-A with the annotate command
to annotate and immediately resubmit in one step:
cmb annotate -a 1:wrong -a 2:reject --auto-annotate \
lib/My/Module.pm
The LLM will honor all dispositions from the prior round, confirm
fixes marked ACCEPT, carry forward DEFER items, and suppress
REJECT and WRONG findings. New findings appear without noise
from settled questions.
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.
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.
ACCEPT
The finding is valid and has been fixed. On the next review the LLM will confirm the fix is present. If the fix is not found the finding will be re-raised.
REJECT
The finding has been reviewed and dismissed as inapplicable to this codebase or context. It will not be raised again in subsequent reviews.
WRONG
The finding was based on faulty reasoning. The code is correct. The finding will not be re-raised. Use this when the LLM has misread the control flow, misunderstood the design intent, or applied an inappropriate threat model.
WRONG-RECONSIDER
Applied automatically at finalization to all findings marked WRONG. On the first review of the next version the LLM will re-examine the specific function and code excerpt carefully. If the prior analysis was still incorrect the finding reverts to WRONG. If the code has changed and the finding is now valid it is raised as a new finding. If the model understands specifically why its prior reasoning was wrong it may mark the finding CONFIRMED.
DEFER
The finding is known and acknowledged but not yet addressed. It is
carried forward in the deferred array of each subsequent review
without being treated as a new finding.
CONFIRMED
Used for logic confirmations rather than defects. Marks that both the LLM and the developer agree the code is correct.
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.
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.
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.
"LLM Commands", "PROMPT PROFILES", CPAN::Maker::ConfigReader
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.
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.
The following profile is installed with the distribution:
cli-tool
Appropriate for single-user developer CLI tools. Suppresses security
findings that assume a multi-user or hostile environment, TOCTOU race
condition findings that assume concurrent invocation, and concerns about
qx{} or system() calls where input originates from the user's own
configuration. Also assumes perlcritic and perltidy are enforced
in the development environment.
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.
library
Focuses on API contract correctness and caller assumptions. Appropriate for CPAN distributions intended for use by unknown callers.
web-application
Treats external input as untrusted. Flags injection risks, authentication gaps, and session handling concerns.
mod-perl-handler
Addresses Apache lifecycle concerns including global state, startup versus request time initialization, and child process behavior.
lambda-function
Focuses on cold start performance, statelessness, and environment variable handling appropriate for AWS Lambda deployments.
Community contributions of additional profiles are welcome. See https://github.com/rlauer6/CPAN-Maker-Bootstrapper/issues.