Skip to content
Merged
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
2 changes: 1 addition & 1 deletion cmd/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ var (
var createCmd = &cobra.Command{
Use: "create [rule-name] [rule-body]",
Short: "Create a new rule using Continue format",
Long: `Create a new rule in the .continue/rules directory using Continue format specification.
Long: `Create a new rule in the current directory using Continue format specification.
If rule parameters are not provided, they will be prompted for interactively.
This command does not modify the rules.json file.`,
Example: ` rules create my-rule "This is the body of the rule"
Expand Down
12 changes: 2 additions & 10 deletions internal/ruleset/ruleset.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,16 +121,8 @@ func CreateRule(rule Rule, format, name string) (string, error) {

content += "---\n\n" + rule.Body

// Determine directory based on format (use Continue format)
ruleDir := ".continue/rules"

// Ensure the directory exists
if err := os.MkdirAll(ruleDir, 0755); err != nil {
return "", err
}

// Create the rule file
fileName := filepath.Join(ruleDir, name+".md")
// Create the rule file in the current directory
fileName := name + ".md"
err := os.WriteFile(fileName, []byte(content), 0644)
if err != nil {
return "", err
Expand Down
10 changes: 5 additions & 5 deletions spec/commands/create.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ rules create --alwaysApply "Always apply this rule" # Body not supplied, so will
## Flags

- `--tags`: Comma-separated list of tags
- `--globs`: Glob patterns to match files (defaults to "**/*" if not specified)
- `--globs`: Glob patterns to match files (defaults to "\*\*/\*" if not specified)
- `--description`: Short description
- `--alwaysApply`: Flag to always apply rule (creates `alwaysApply: true` in frontmatter)

Expand All @@ -27,10 +27,9 @@ rules create --alwaysApply "Always apply this rule" # Body not supplied, so will

- Prompts for missing fields if not provided
- Allows for stdin/editor input for rule body
- Creates a new rule (.md) file in `.continue/rules/` directory following Continue format
- Creates a new rule (.md) file in the current directory following Continue format
- Uses Continue frontmatter format with `alwaysApply`, `description`, and `globs` fields
- Does not modify the rules.json file
- Automatically creates `.continue/rules/` directory if it doesn't exist

## Continue Format Output

Expand All @@ -47,8 +46,9 @@ globs: "**/*.tsx"
```

### Frontmatter Fields:

- `alwaysApply`: boolean - Whether to always apply the rule (set via `--alwaysApply` flag)
- `description`: string - Short description of the rule (set via `--description` flag)
- `globs`: string - Glob patterns to match files (set via `--globs` flag, defaults to "**/*")
- `globs`: string - Glob patterns to match files (set via `--globs` flag, defaults to "\*\*/\*")

Note: Tags are not part of the Continue format specification and will be omitted from the frontmatter.
Note: Tags are not part of the Continue format specification and will be omitted from the frontmatter.