From 7cc8cd6127da3645e56c15b73a9ad0ba990b85d3 Mon Sep 17 00:00:00 2001 From: Vincenzo Incutti Date: Mon, 4 Aug 2025 14:02:13 +0100 Subject: [PATCH] Recurse rules --- .recurseml.yaml | 1 + .rules/avoid_source_deduplication.mdc | 28 +++++++++++++++++++ .rules/consistent_container_image_sources.mdc | 28 +++++++++++++++++++ .rules/no_env_files_in_repo.mdc | 22 +++++++++++++++ .rules/require_unique_id_props.mdc | 28 +++++++++++++++++++ 5 files changed, 107 insertions(+) create mode 100644 .recurseml.yaml create mode 100644 .rules/avoid_source_deduplication.mdc create mode 100644 .rules/consistent_container_image_sources.mdc create mode 100644 .rules/no_env_files_in_repo.mdc create mode 100644 .rules/require_unique_id_props.mdc diff --git a/.recurseml.yaml b/.recurseml.yaml new file mode 100644 index 0000000..225cc5b --- /dev/null +++ b/.recurseml.yaml @@ -0,0 +1 @@ +rules: .rules/ \ No newline at end of file diff --git a/.rules/avoid_source_deduplication.mdc b/.rules/avoid_source_deduplication.mdc new file mode 100644 index 0000000..e5fa19b --- /dev/null +++ b/.rules/avoid_source_deduplication.mdc @@ -0,0 +1,28 @@ +```yaml +name: avoid-source-deduplication +description: Preserve unique source entries in search results to maintain proper citation tracking +globs: ['**/connector_service.py', '**/search_service.py'] +alwaysApply: true +``` + +Search result processing should preserve all source entries to maintain accurate citation tracking, rather than deduplicating sources. + +❌ Bad - Deduplicating sources: +```python +mapped_sources = {} +for chunk in chunks: + source_key = chunk.get('url') or chunk.get('title') + if source_key not in mapped_sources: + mapped_sources[source_key] = create_source(chunk) +sources_list = list(mapped_sources.values()) +``` + +✅ Good - Preserving unique sources: +```python +sources_list = [] +for chunk in chunks: + source = create_source(chunk) + sources_list.append(source) +``` + +Each chunk should maintain its unique source reference for proper citation tracking. \ No newline at end of file diff --git a/.rules/consistent_container_image_sources.mdc b/.rules/consistent_container_image_sources.mdc new file mode 100644 index 0000000..ff3115b --- /dev/null +++ b/.rules/consistent_container_image_sources.mdc @@ -0,0 +1,28 @@ +```yaml +name: consistent-container-image-sources +description: Maintain consistent image sources in Docker compose files using authorized registries +globs: ['**/docker-compose.yml', '**/docker-compose.*.yml'] +alwaysApply: true +``` + +Docker compose files should use consistent image sources from authorized registries rather than local builds in production configurations. + +❌ Bad - Mixing build and image sources: +```yaml +services: + frontend: + build: ./frontend + backend: + image: ghcr.io/org/backend:latest +``` + +✅ Good - Consistent image sources: +```yaml +services: + frontend: + image: ghcr.io/org/frontend:latest + backend: + image: ghcr.io/org/backend:latest +``` + +Use build contexts only in development compose files. \ No newline at end of file diff --git a/.rules/no_env_files_in_repo.mdc b/.rules/no_env_files_in_repo.mdc new file mode 100644 index 0000000..baac119 --- /dev/null +++ b/.rules/no_env_files_in_repo.mdc @@ -0,0 +1,22 @@ +```yaml +name: no-env-files-in-repo +description: Prevent committing environment and configuration files containing sensitive credentials +globs: ['**/.env', '**/.env.*', '**/config/*.yml', '**/config/*.yaml'] +alwaysApply: true +``` + +Configuration files like `.env` should never be committed to version control as they often contain sensitive information like API keys, passwords, and tokens. + +❌ Bad - Committing .env files: +``` +POSTGRES_DATABASE_URL=postgresql+psycopg2://user:password@localhost:5432/db +API_KEY=sk-1234567890abcdef +``` + +✅ Good - Use .env.example instead: +``` +POSTGRES_DATABASE_URL=postgresql+psycopg2://user:password@host:5432/dbname +API_KEY=your-api-key-here +``` + +Add `.env` and similar config files to .gitignore and provide example templates instead. \ No newline at end of file diff --git a/.rules/require_unique_id_props.mdc b/.rules/require_unique_id_props.mdc new file mode 100644 index 0000000..33adbc5 --- /dev/null +++ b/.rules/require_unique_id_props.mdc @@ -0,0 +1,28 @@ +```yaml +name: require-unique-id-props +description: Ensure unique key props are provided when mapping arrays to React elements +globs: ['**/*.tsx', '**/*.jsx'] +alwaysApply: true +``` + +When mapping arrays to React elements, each element must have a unique key prop to help React efficiently update the DOM. + +❌ Bad - Missing key prop: +```jsx +{items.map((item) => ( + + {item.name} + +))} +``` + +✅ Good - With key prop: +```jsx +{items.map((item) => ( + + {item.name} + +))} +``` + +Keys should be stable, predictable, and unique among siblings. \ No newline at end of file