Plexure API Search with Cursor
Comprehensive Cursor rules for building and maintaining a code search application that efficiently searches and analyzes code across various repositories. Integrates with CSV databases and automates processes using GitHub Actions.
Code Preservation Rules
When working on this codebase, always follow these preservation principles:
**Never remove existing code** that is not directly related to the current change scope**Always maintain existing functionality** unless explicitly requested to change**Keep all existing imports and dependencies** unless they are specifically being refactored**Preserve existing error handling and logging mechanisms****Maintain existing configuration options and defaults****Keep all existing CLI commands and their functionality****Do not remove or modify existing tests** unless they are directly related to changes**Preserve existing documentation** unless it needs to be updated for new changesFile Structure and Responsibilities
Core Files
**searcher.py** - Search engine core logic, query processing, and result ranking**indexer.py** - API contract indexing, vector creation, and database management**embeddings.py** - Vector embedding generation and model management**cli.py** - Command-line interface and user interaction handling**config.py** - Configuration management and environment variables**cache.py** - Caching mechanisms for search results and embeddings**metrics.py** - Performance tracking and statistical measurements**validation.py** - Input validation and data sanitization**boosting.py** - Search result ranking and score boosting logic**expansion.py** - Query expansion and enhancement**consistency.py** - Data consistency and validation checks**quality.py** - Search quality metrics and improvements**understanding.py** - Natural language processing and query understanding**monitoring.py** - System monitoring and loggingSupport Files
**__init__.py** - Package initialization and version info**__main__.py** - Entry point for command-line executionConfiguration Files (project root)
**pyproject.toml** - Project metadata and dependencies**poetry.lock** - Locked dependency versions**.env** - Environment variables (not in git)**.env.sample** - Example environment variables**.gitignore** - Git ignore patterns**README.md** - Project documentation**LICENSE** - Project license**NOTICE** - Third-party noticesDocumentation Files (docs/ directory)
**api.md** - API documentation**architecture.md** - System architecture**deployment.md** - Deployment guide**development.md** - Development guide**testing.md** - Testing guideCode Style Guidelines
Follow **PEP 8** style guidelines for Python codeUse **type hints** for all function parameters and return valuesMaximum line length: **100 characters**Use **docstrings** for all public functions and classesUse consistent naming conventions across all filesAdd comments for complex logic or business rulesKeep functions focused and single-purposeUse meaningful variable names that describe their purposeProject Structure Principles
Keep all core logic in `plexure_api_search/` directoryPlace all tests in `tests/` directoryStore configuration files in project rootKeep documentation in `docs/` directoryOrganize modules by feature/domainUse `__init__.py` files to control public APIs**Circular dependencies are strictly forbidden**Maintain clear separation of concernsTesting Standards
Write **unit tests** for all new functionalityMaintain test coverage **above 80%**Place tests in `tests/` directoryName test files with `test_` prefixTest files must match source file namesInclude integration tests for critical pathsMock external dependencies appropriatelyTest error conditions and edge casesUse pytest fixtures for common setupInclude performance tests for critical operationsDocumentation Requirements
Document all public APIs with docstringsKeep README.md up to date with new featuresInclude usage examples in docstringsDocument complex algorithms with commentsMaintain API documentation in `docs/`Include type hints in documentationDocument error conditions and handlingKeep configuration options documentedInclude troubleshooting guidesDependency Management
Use **Poetry** for dependency managementPin dependency versions in `pyproject.toml`Keep dependencies up to dateDocument new dependencies in README.mdUse `requirements-dev.txt` for development dependenciesMake optional dependencies truly optionalHandle dependency conflicts gracefullyDocument minimum version requirementsTest with multiple Python versionsEnvironment Configuration
Use `.env` for environment variables**Never commit sensitive data**Keep `.env.sample` updatedUse **Python 3.9 or higher**Document all environment variablesProvide default values when appropriateValidate environment variables at startupHandle missing variables gracefullySupport different environments (dev/prod)Model Management
Use public, well-established models by defaultHandle model loading errors gracefullyImplement fallback models for robustnessCache model artifacts appropriatelyMonitor model performance metricsSupport model versioningHandle tokenization errors gracefullyValidate model compatibilityDocument model requirements and limitationsError Handling
Use specific exception typesLog errors with appropriate contextImplement graceful fallbacksValidate inputs earlyHandle resource cleanup properlyProvide meaningful error messagesInclude error recovery mechanismsMonitor error rates and patternsDocument error handling proceduresPerformance Optimization
Cache expensive operationsUse vectorized operations where possibleMonitor memory usageKeep response times **under 200ms**Profile performance-critical codeImplement request timeoutsUse connection poolingImplement rate limitingMonitor resource utilizationOptimize database queriesSecurity Best Practices
Validate all inputsSanitize API responsesUse environment variables for secretsFollow security best practices**Never log sensitive data**Implement rate limitingUse secure communicationValidate authentication tokensImplement access controlsMonitor security eventsMonitoring and Observability
Log important operationsTrack performance metricsMonitor error ratesUse structured loggingImplement health checksTrack resource utilizationMonitor API latenciesImplement alertingTrack business metricsMonitor cache effectivenessVersion Control Guidelines
Write clear commit messagesFollow **semantic versioning**Keep feature branches smallMerge only after tests passUse **conventional commits** formatReview code changesMaintain changelogTag releases properlyDocument breaking changesKeep main branch stableUsage Example
When working in Cursor, these rules will automatically guide your development:
1. **Making changes**: Always preserve existing code not related to your change
2. **Adding features**: Write tests first, maintain >80% coverage
3. **Refactoring**: Keep existing functionality intact, update tests if needed
4. **Documentation**: Update docstrings and README.md for any public API changes
5. **Dependencies**: Use Poetry to add new dependencies, document in README
6. **Performance**: Profile before optimizing, maintain <200ms response times
7. **Security**: Validate all inputs, never commit secrets
Important Constraints
Python 3.9+ requiredPoetry for dependency managementPytest for testing (>80% coverage)PEP 8 style guidelines100 character line limitNo circular dependenciesNever commit sensitive dataNever remove unrelated code