agentleFS
marianfoomarianfoo/mcp-sap-docs/.cursor/rules/50-metadata-config.mdc

mcp-sap-docs / rules

Cursor rule243 starsChanged 6 months agoApache-2.0View on GitHub

For centralized configuration management and metadata-driven features. @file src/metadata.json @file src/lib/metadata.ts @file src/lib/config.ts @file docs/METADATA-CONSOLIDATION.md @file docs/ARCHITECTURE.md @file docs/DEV.md

We split this 50-metadata-config.mdc into the rules it gives an agent

6 rules. About 0 are common, 4 are distinctive, and 2 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈4

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Add source definition to src/metadata.json

    line 32
  2. Distinctive:

    Add to contextBoosts if context-specific scoring needed

    line 34
  3. Distinctive:

    Add to libraryMappings if ID mapping required

    line 35
  4. Distinctive:

    No code changes needed - APIs handle automatically

    line 36
  5. Very specific:

    Single Source: All source configs in metadata.json only

    line 39
  6. Distinctive:

    Type Safety: Use metadata APIs, never direct JSON access

    line 40

≈ “Common” is an estimate: at least 1 in 5 of the 6,350 Cursor rule files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
50-metadata-config.mdc
# Metadata & Configuration (Rule)

For centralized configuration management and metadata-driven features.

## Metadata System Architecture
- **Central Config**: `src/metadata.json` - Single source of truth
- **Type-Safe APIs**: `src/lib/metadata.ts` - 12 comprehensive functions
- **Core Settings**: `src/lib/config.ts` - System-level configuration only
- **Runtime Loading**: Metadata loaded once at startup with fallbacks

## Configuration Structure
```json
{
  "sources": [/* 12 documentation sources with full metadata */],
  "contextBoosts": {/* Context-specific scoring boosts */},
  "libraryMappings": {/* Source ID to library ID mappings */},
  "contextEmojis": {/* UI presentation emojis */},
  "synonyms": [/* Query expansion synonyms */],
  "acronyms": {/* Acronym expansions */}
}
```

## Metadata APIs (12 functions)
- **URL Configuration**: `getDocUrlConfig()`, `getAllDocUrlConfigs()`
- **Source Paths**: `getSourcePath()`, `getAllSourcePaths()`
- **Context Boosts**: `getContextBoosts()`, `getAllContextBoosts()`
- **Library Mappings**: `getLibraryMapping()`, `getAllLibraryMappings()`
- **UI Elements**: `getContextEmoji()`, `getAllContextEmojis()`
- **Source Lookup**: `getSourceByLibraryId()`, `getSourceById()`

## Adding New Sources
1. Add source definition to `src/metadata.json`
2. Include: id, libraryId, sourcePath, baseUrl, pathPattern, anchorStyle, boost, tags
3. Add to contextBoosts if context-specific scoring needed
4. Add to libraryMappings if ID mapping required
5. No code changes needed - APIs handle automatically

## Configuration Best Practices
- **Single Source**: All source configs in metadata.json only
- **Type Safety**: Use metadata APIs, never direct JSON access
- **Fallbacks**: APIs return sensible defaults for missing data
- **Validation**: Metadata loading includes error handling
- **Environment**: Core settings can be overridden via env vars

## Migration from Hardcoded Config
- **Before**: Scattered configs in multiple files (~250+ lines)
- **After**: Centralized metadata with type-safe access
- **Benefits**: Maintainable, extensible, no code changes for new sources

@file src/metadata.json
@file src/lib/metadata.ts
@file src/lib/config.ts
@file docs/METADATA-CONSOLIDATION.md
@file docs/ARCHITECTURE.md
@file docs/DEV.md

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.