feat: add --targets and --features filtering to gitignore command#1309
Conversation
…mand Extract gitignore entries into a tagged registry (gitignore-entries.ts) with target and feature metadata, enabling users to filter .gitignore output by specific tools and features (e.g., --targets claudecode --features rules,commands). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Adds filtering support to the rulesync gitignore CLI by moving ignore patterns into a tagged registry and generating .gitignore entries based on selected tool targets and features.
Changes:
- Introduces a tagged gitignore entry registry and filtering helper (
filterGitignoreEntries). - Adds
--targetsand--featuresoptions to therulesync gitignorecommand and plumbs them into generation. - Updates unit tests and refreshes the repository’s generated
.gitignoreblock ordering/content.
Reviewed changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| src/cli/index.ts | Adds --targets / --features options for the gitignore subcommand and forwards them to the handler. |
| src/cli/commands/gitignore.ts | Switches gitignore generation/removal to use the registry + filtering output. |
| src/cli/commands/gitignore.test.ts | Updates tests to use the filtered registry output; adds new filter behavior tests. |
| src/cli/commands/gitignore-entries.ts | New registry of ignore patterns with target/feature tags and filtering logic. |
| src/cli/commands/gitignore-entries.test.ts | New tests covering registry completeness and filter combinations. |
| .gitignore | Updates the committed generated Rulesync block to match the new registry ordering/content. |
You can also share your feedback on Copilot code review. Take the survey.
| .option( | ||
| "-t, --targets <tools>", | ||
| "Comma-separated list of tools to include (e.g., 'claudecode,copilot' or '*' for all)", | ||
| (value) => { | ||
| return value.split(",").map((t) => t.trim()); | ||
| }, | ||
| ) | ||
| .option( | ||
| "-f, --features <features>", | ||
| `Comma-separated list of features to include (${ALL_FEATURES.join(",")}) or '*' for all`, | ||
| (value) => { | ||
| return value.split(",").map((f) => f.trim()); | ||
| }, | ||
| ) | ||
| .action(async (options) => { | ||
| await gitignoreCommand({ | ||
| targets: options.targets, | ||
| features: options.features, | ||
| }); | ||
| }); |
| // copilot rules should be included (no restriction for copilot rules - targetFeatures not specified means all) | ||
| // Wait, copilot has ["commands"] so rules should NOT be included |
|
|
||
| // Cline | ||
| { target: "cline", feature: "rules", entry: "**/.clinerules/" }, | ||
| { target: "cline", feature: "rules", entry: "**/.clinerules/workflows/" }, |
| // Kilo Code | ||
| { target: "kilo", feature: "rules", entry: "**/.kilocode/rules/" }, | ||
| { target: "kilo", feature: "skills", entry: "**/.kilocode/skills/" }, | ||
| { target: "kilo", feature: "skills", entry: "**/.kilocode/workflows/" }, |
| // Object format: per-target features | ||
| if (target === "common") return true; | ||
| const targetFeatures = features[target]; | ||
| if (!targetFeatures) return true; |
… gitignore command Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Fix .clinerules/workflows/ tag from rules to commands (matches ClineCommand) - Fix .kilocode/workflows/ tag from skills to commands (matches KiloCommand) - Add validation warnings for invalid targets/features in filterGitignoreEntries - Filter empty strings from CLI option parsers - Fix contradictory test comment in per-target feature test - Document intentional semantic difference from Config.getFeatures() Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Adds filtering capabilities to the rulesync gitignore CLI command by extracting gitignore patterns into a tagged registry and allowing users (and programmatic callers) to select subsets by tool target and/or feature.
Changes:
- Introduces
--targetsand--featuresoptions onrulesync gitignoreand wires them intogitignoreCommand. - Extracts gitignore patterns into
gitignore-entries.tswithtarget/featuremetadata and filtering logic. - Updates tests and the repo’s tracked
.gitignoreRulesync block to reflect the new entry source/order.
Reviewed changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/cli/index.ts | Adds --targets / --features parsing for gitignore command. |
| src/cli/commands/gitignore.ts | Uses the new registry + filtering to generate the Rulesync gitignore block while still removing all known Rulesync entries. |
| src/cli/commands/gitignore.test.ts | Refactors “up to date” fixtures and adds coverage for target/feature filtering behavior. |
| src/cli/commands/gitignore-entries.ts | New tagged registry of gitignore entries and filtering/validation helpers. |
| src/cli/commands/gitignore-entries.test.ts | New unit tests validating registry integrity, filtering, warnings, and deduplication. |
| .gitignore | Updates the generated Rulesync block to match the new registry ordering/content. |
You can also share your feedback on Copilot code review. Take the survey.
| const warnInvalidTargets = (targets: ReadonlyArray<string>): void => { | ||
| const validTargets = new Set<string>(ALL_TOOL_TARGETS_WITH_WILDCARD); | ||
| for (const target of targets) { | ||
| if (!validTargets.has(target)) { | ||
| logger.warn( | ||
| `Unknown target '${target}'. Valid targets: ${ALL_TOOL_TARGETS_WITH_WILDCARD.join(", ")}`, | ||
| ); | ||
| } | ||
| } | ||
| }; |
Add --targets and --features documentation to cli-commands.md with options table, examples, and behavior notes. Add filtered examples to quick-start.md. Add test to document targets intentionally excluded from the registry. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Summary
gitignore-entries.ts) withtargetandfeaturemetadata per entry--targetsand--featuresCLI options to therulesync gitignorecommand for filtering output--features rules,commands) for CLI and object format ({ "copilot": ["rules"] }) for programmatic use.rulesync/skills/.curated/) and general entries (e.g., memories, settings) are always included when their target is selected.clinerules/workflows/→ commands,.kilocode/workflows/→ commandsTest plan
pnpm vitest run src/cli/commands/gitignore— 46 tests passpnpm dev gitignore— full output (backward compatible)pnpm dev gitignore --targets claudecode— Claude Code entries onlypnpm dev gitignore --targets copilot --features rules,commands— combined filterpnpm cicheck— all checks pass🤖 Generated with Claude Code