Skip to content

feat: detect or select LLM providers for injection targets #128

@pertrai1

Description

@pertrai1

Problem

npx llm-core-instructions currently injects references into a hardcoded list of three files (AGENTS.md, CLAUDE.md, .github/copilot-instructions.md) based solely on whether they exist on disk. This has two gaps:

  1. Missing providers — Cursor (.cursor/rules/), Windsurf (.windsurfrules), Cline (.clinerules), Gemini (GEMINI.md), Aider (CONVENTIONS.md), and Continue.dev (.continue/rules/) are not in the target list at all.

  2. No provider awareness — The CLI doesn't know which providers are actually in use. A team that switched from Copilot to Claude still has .github/copilot-instructions.md sitting around and gets an injection into a file nobody reads.

Provider Landscape

Based on research across current documentation and open-source implementations, here are the well-known instruction file locations:

Provider Instruction File(s) Config Marker
Claude Code CLAUDE.md .claude/settings.json
GitHub Copilot .github/copilot-instructions.md
Cursor .cursor/rules/*.mdc, .cursorrules (legacy) .cursor/ directory
Windsurf .windsurf/rules/*.md, .windsurfrules (legacy) .codeiumignore
Cline .clinerules .clinerules/ directory
Gemini CLI GEMINI.md .gemini/settings.json
Aider CONVENTIONS.md (via --read) .aider.conf.yml
Continue.dev .continue/rules/*.md ~/.continue/config.yaml
OpenCode AGENTS.md AGENTS.md

Relative Path Considerations

Each target file needs a correct relative path to .agents/linting-rules.md:

  • Root-level files (AGENTS.md, CLAUDE.md, GEMINI.md, .cursorrules, .windsurfrules, .clinerules): .agents/linting-rules.md
  • .github/ files: ../.agents/linting-rules.md
  • .cursor/rules/ files: ../../.agents/linting-rules.md
  • .windsurf/rules/ files: ../../.agents/linting-rules.md
  • .continue/rules/ files: ../../.agents/linting-rules.md

Open Questions

These need to be answered before implementation:

1. Auto-detect, user-select, or both?

  • Auto-detect only: Check for config marker files (.claude/settings.json, .cursorrules, .aider.conf.yml, etc.) to determine which providers are in use. No user input needed.
  • User-select only: Add --providers copilot,cursor flag. User explicitly specifies which providers to target.
  • Both (recommended): Auto-detect by default, allow --providers to override. This matches the behavior of tools like rule-porter and agentmd.

2. Should injection create missing files?

Currently the CLI only injects into files that already exist. Should --providers cursor create .cursor/rules/llm-core.mdc if Cursor is selected but the file doesn't exist yet? Or should it only inject into existing files and skip missing ones?

3. How to handle providers with directory-based rules?

Cursor (.cursor/rules/*.mdc) and Windsurf (.windsurf/rules/*.md) support multiple rule files with YAML frontmatter. Should we:

  • Create a dedicated file (e.g., .cursor/rules/llm-core.mdc)?
  • Append to an existing file if one exists?
  • Both?

4. What about providers without a standard injection point?

Aider uses CONVENTIONS.md but only loads it via --read flag. Is injecting into CONVENTIONS.md useful if the user has to manually configure Aider to read it?

5. Should the injection block format vary by provider?

Currently all providers get the same markdown block. Some providers support richer formats:

  • Cursor MDC files support YAML frontmatter with description, globs, alwaysApply
  • Continue.dev rules support .ctx files with metadata
  • Should we add provider-specific frontmatter when targeting these formats?

6. How to handle the AGENTS.md overlap?

AGENTS.md is recognized by Claude Code, GitHub Copilot, OpenCode, and others. If a user has AGENTS.md and CLAUDE.md, injecting into both is redundant. Should we:

  • Always inject into AGENTS.md as the universal target?
  • Skip CLAUDE.md if AGENTS.md is present?
  • Let the user decide?

Prior Art

  • rule-porter (nedcodes-ok/rule-porter) — detectSource() checks for .cursor/rules/, .cursorrules, .windsurfrules, AGENTS.md, CLAUDE.md, .github/copilot-instructions.md
  • agentmd (mikiships/agentmd) — Scans project and generates instruction files for Claude Code, Cursor, Copilot, Windsurf, and AGENTS.md
  • Cline (cline/cline) — Reads .cursor/rules/*.mdc, .clinerules, and .github/copilot-instructions.md from external-rules.ts
  • Next.js create-next-app (vercel/next.js) — Generates AGENTS.md and CLAUDE.md by default via generate-agent-files.ts

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions