Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,35 @@ Added new feature X that does Y.
Fixed bug Z in the parser.
```

## Custom AI Instructions

Override the default AI prompt by placing an `instructions.md` file in your `.changelog/` directory:

`.changelog/instructions.md`:

The file contents are used as the prompt template. Use `{packages}` and `{diff}` as placeholders:

```markdown
Generate a changelog entry for this diff.

Available packages: {packages}

---
<package-name>: patch
---

Description.

Version rules:
- "major": any removal or rename of public API
- "minor": new features
- "patch": bug fixes, internal changes

{diff}
```

Priority: `--instructions` flag > `.changelog/instructions.md` > built-in default.

## Supported AI Providers

The `--ai` flag and GitHub Action `ai` input accept any CLI command that reads from stdin and outputs text. The diff is piped to the command, and the output becomes the changelog entry.
Expand Down
10 changes: 9 additions & 1 deletion src/cli/add.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,15 @@ fn run_ai_generation(
diff_to_use
};

let template = instructions.unwrap_or(DEFAULT_INSTRUCTIONS);
let instructions_file = workspace.changelog_dir().join("instructions.md");
let file_instructions = if instructions.is_none() && instructions_file.exists() {
std::fs::read_to_string(&instructions_file).ok()
} else {
None
};
let template = instructions
.or(file_instructions.as_deref())
.unwrap_or(DEFAULT_INSTRUCTIONS);
let prompt = template
.replace("{packages}", &package_names)
.replace("{diff}", &diff_to_use);
Expand Down
Loading