Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ This package includes the following Cursor rule and command templates:
1. **readme-async-messaging.mdc** - Auto-update README with async messaging architecture
2. **readme-config.mdc** - Auto-update README with configuration section
3. **readme-data-model.mdc** - Auto-update README with data model documentation
4. **readme-summary.mdc** - Auto-update README with summary section
4. **readme-development.mdc** - Auto-update README with project setup and development instructions
5. **readme-content.mdc** - Auto-update README overall, defining document sections and which template are intended to use on each one
6. **readme-summary.mdc** - Auto-update README with summary section

### Commands (.cursor/commands/)
1. **update-docs.md** - Command to update project documentation
Expand Down
2 changes: 2 additions & 0 deletions templates/commands/update-docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,5 @@ This file contains commands and instructions for updating project documentation.
**When:** Config files detected (`src/config/`, `.env`, etc.)
**Apply rules:** `readme-config.mdc`

**When:** Project wide files changed (`.nvmrc`, `package.json`, `src/app.module.ts`, `Dockerfile`, `.github/workflows/*.yml`, etc)
**Apply rules:** `readme-development.mdc`
2 changes: 1 addition & 1 deletion templates/rules/readme-async-messaging.mdc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
globs: src/config/*.ts
globs: "src/config/*.ts"
---
# Async Messaging README Auto-update

Expand Down
7 changes: 6 additions & 1 deletion templates/rules/readme-config.mdc
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
---
globs: src/config/*, .helm/values.yaml, .github/workflows/*.yml, src/app.module.ts, package.json
globs:
- "src/config/*"
- ".helm/values.yaml"
- ".github/workflows/*.yml"
- "src/app.module.ts"
- "package.json"
---
# Configuration README Auto-update

Expand Down
180 changes: 180 additions & 0 deletions templates/rules/readme-content.mdc
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
---
globs:
- "./**/*.ts"
- "./**/*.yml"
- ".env"
- "./*.json"
- "./src/config/*"
alwaysApply: false
description: "Overall standard structure for README.md content"
---
# README Content Generation Rules

## Auto-update README Content

When the README.md file is modified or when the project structure changes, automatically update the README.md file with a comprehensive structure that includes:

0. Index or list of sections with links to each one
1. A description section with component type and purpose
2. Data Model section (for microservices/backend services)
3. Async Messaging section (for microservices/backend services)
4. Configuration section (for all code repositories)
5. Standard project setup and deployment sections

## README Structure Template

The README should follow this structure:

```markdown
# [Project Name]

[Optional: Project logo or banner]

## Content
- [Description](link_to_description_section)
- [Data model](link_to_data_model_section)
- [Async messaging](link_to_async_messaging_section)
- [Configuration](link_to_configuration_section)
- [Setup and development](link_to_the_setup_project_section)

## Description

[Component Type]: [Brief description of what the component does]

[Detailed description of the component's purpose, functionality, and role in the system]

[Additional context about the component's responsibilities and key features]

## Data Model

[Only for microservices and backend services - follows readme-data-model.mdc rules]

## Async Messaging

[Only for microservices and backend services - follows readme-async-messaging.mdc rules]

## Configuration

[For all code repositories - follows readme-config.mdc rules]

## Setup and development

[For all code repositories - follows readme-development.mdc rules]
```

## Component Type Detection

The system should automatically detect the component type based on project structure and dependencies and follows readme-development.mdc accordingly:

### Microservice/Backend Service Indicators:
- NestJS framework (`@nestjs/core` in package.json)
- Database entities in `src/domain/models/`
- Configuration files in `src/config/`
- AMQP/RabbitMQ configuration
- Database migrations
- API controllers

### Web Application Indicators:
- Frontend frameworks (React, Vue, Angular, etc.)
- Build tools (Webpack, Vite, etc.)
- Static assets directories
- Browser-specific dependencies

### Library/Package Indicators:
- Library-specific `package.json` structure
- TypeScript declaration files
- Minimal runtime dependencies
- Export/import focused structure


## Description Generation Rules

### For Microservices/Backend Services:
```markdown
**Microservice**: [Service name and primary responsibility]

[Detailed description including:]
- Primary business function
- Key responsibilities
- Integration points with other services
- Data processing capabilities
- API endpoints or message handling
```

### For Web Applications:
```markdown
**Web Application**: [Application name and purpose]

[Detailed description including:]
- User-facing functionality
- Key features and capabilities
- Target user base
- Technology stack
- Deployment considerations
```

### For Libraries/Packages:
```markdown
**Library**: [Package name and functionality]

[Detailed description including:]
- Core functionality provided
- Target use cases
- API surface
- Integration requirements
- Version compatibility
```

## Section Inclusion Rules

### Data Model Section
- **Include when**: Component type is "Microservice" or "Backend Service"
- **Trigger**: Files in `src/domain/models/` are modified
- **Content**: Follows readme-data-model.mdc rules

### Async Messaging Section
- **Include when**: Component type is "Microservice" or "Backend Service" AND RabbitMQ configuration exists
- **Trigger**: Files in `src/config/` are modified
- **Content**: Follows readme-async-messaging.mdc rules

### Configuration Section
- **Include when**: All component types (Microservice, Backend Service, Web Application, Library)
- **Trigger**: Configuration files are modified (e.g., `src/config/`, `.env`, `package.json`, etc.)
- **Content**: Follows readme-config.mdc rules

### Setup and Development Section
- **Include when**: All component types (Microservice, Backend Service, Web app or Library/Package)
- **Trigger**: Configuration, infra or CI/CD files modified (e.g. `src/config`, `package.json`, `Dockerfile`, etc.)
- **Content**: Follows @readme-development.mdc

### Standard Sections
- **Always include**: Description

## Update Triggers

The README should be updated when:

1. **README.md is directly modified** - Regenerate entire structure
2. **Package.json changes** - Update component type detection, dependencies and setup sections
3. **Domain models change** - Update Data Model section
4. **Configuration changes** - Update Async Messaging and Configuration sections
5. **Infrastructure, CI/CD changes** - Update setup section
6. **New major features added** - Update description and relevant sections

## Implementation Notes

- Use TypeScript AST parsing to analyze project structure
- Extract component type from package.json and file structure
- Generate appropriate description based on detected component type
- Maintain existing content when possible, only updating relevant sections
- Ensure Mermaid diagrams are properly formatted and valid
- Preserve custom content while standardizing structure
- Handle edge cases gracefully (missing files, malformed configurations, etc.)

## Content Preservation

- Always preserve existing custom content in sections
- Only replace auto-generated sections (Data Model, Async Messaging, Configuration)
- Maintain user-added sections and custom descriptions
- Preserve formatting and styling preferences
- Keep project-specific information intact
2 changes: 1 addition & 1 deletion templates/rules/readme-data-model.mdc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
globs: src/domain/models/*
globs: "src/domain/models/*"
---
# Data Model README Auto-update

Expand Down
Loading