feat(cli): enhance /init command to create custom slash command (#7888)

* feat(cli): enhance /init command to create custom slash command

Update the /init slash command prompt to also create a custom "review"
slash command file at .continue/rules/review.md with invokable frontmatter
and review-focused instructions.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* fix: address feedback

---------

Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
Nate Sesti 2025-09-25 11:39:57 -07:00 • committed by GitHub
parent 72ad501f73
commit 268329a944
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 30 additions and 6 deletions

View file

@ -4,6 +4,15 @@ import {
} from "@continuedev/config-yaml";
import { joinPathsToUri } from "../../util/uri";
function createRelativeRuleFilePathParts(ruleName: string): string[] {
const safeRuleName = sanitizeRuleName(ruleName);
return [".continue", "rules", `${safeRuleName}.${RULE_FILE_EXTENSION}`];
}
export function createRelativeRuleFilePath(ruleName: string): string {
return createRelativeRuleFilePathParts(ruleName).join("/");
}
/**
* Creates the file path for a rule in the workspace .continue/rules directory
*/
@ -11,11 +20,8 @@ export function createRuleFilePath(
workspaceDir: string,
ruleName: string,
): string {
const safeRuleName = sanitizeRuleName(ruleName);
return joinPathsToUri(
workspaceDir,
".continue",
"rules",
`${safeRuleName}.${RULE_FILE_EXTENSION}`,
...createRelativeRuleFilePathParts(ruleName),
);
}

View file

@ -1,9 +1,11 @@
import { type AssistantConfig } from "@continuedev/sdk";
import { createRelativeRuleFilePath } from "core/config/markdown/utils.js";
import { SlashCommandResult } from "../ui/hooks/useChat.types.js";
function createInitPrompt(): string {
return `Please analyze this repository and create a comprehensive AGENTS.md file. Use your available tools to understand the project structure, read important files like README.md, package.json, requirements.txt, and other configuration files to understand the technology stack and setup.
const relativeRuleFilepath = createRelativeRuleFilePath("review");
return `Please analyze this repository and create a comprehensive AGENTS.md file, along with a custom slash command. Use your available tools to understand the project structure, read important files like README.md, package.json, requirements.txt, and other configuration files to understand the technology stack and setup.
Create an AGENTS.md file with the following structure:
@ -30,7 +32,23 @@ Create an AGENTS.md file with the following structure:
- Development environment setup
- Lint and format commands
Please create the AGENTS.md file using the Write tool after analyzing the repository. Focus on providing actionable information that would help both AI agents and human developers understand and work effectively with this codebase. Keep the file concise but informational.`;
Additionally, create a slash command file at ${relativeRuleFilepath} with the following structure:
\`\`\`md
---
invokable: true
---
Review this code for potential issues, including:
<insert custom things to look for based on the repository details you find>
Provide specific, actionable feedback for improvements.
\`\`\`
This slash command will be invokable using /review and will provide instructions for code review tasks common to this repository.
Please create both the AGENTS.md file and the .continue/rules/review.md file using the Write tool after analyzing the repository. Focus on providing actionable information that would help both AI agents and human developers understand and work effectively with this codebase. Keep the files concise but informational.`;
}
export async function handleInit(