### Example Installation Quick Start (Bash) Source: https://github.com/aios-labs/projectrules/blob/main/data/rules/manual/readme-md.md Provides example Bash commands for quickly installing the project, including single-command and step-by-step options. ```bash # Single command installation npm install my-package # Or step by step git clone https://github.com/user/repo cd repo npm install npm start ``` -------------------------------- ### Starting the Project with Bun (Bash) Source: https://github.com/aios-labs/projectrules/blob/main/data/rules/manual/running-the-project.md Runs the project using the Bun runtime. This command typically starts the development server. ```bash bun start ``` -------------------------------- ### Installing @microsoft/fast-element with npm Source: https://github.com/aios-labs/projectrules/blob/main/data/rules/manual/fast-quick-start.md Command to install the `@microsoft/fast-element` package as a project dependency using the npm package manager. ```Bash npm install --save @microsoft/fast-element ``` -------------------------------- ### Example Directory Structure for pdoc Source: https://github.com/aios-labs/projectrules/blob/main/data/rules/manual/pdoc.md Illustrates a recommended directory and package structure for Python projects to facilitate effective documentation generation with pdoc, emphasizing the role of `__init__.py` files. ```text my_project/ ├── my_package/ │ ├── __init__.py # Package-level docstring here │ ├── module_a.py # Contains functions and classes │ ├── module_b.py # Contains more functions and classes │ └── subpackage/ │ ├── __init__.py # Subpackage-level docstring here │ └── module_c.py # Contains functions and classes └── setup.py # Installation script ``` -------------------------------- ### Installing Prisma Dependencies (Bash) Source: https://github.com/aios-labs/projectrules/blob/main/data/rules/manual/prisma-McCarthyFinch-webinar-project.md Installs the Prisma client library and the Prisma CLI as a development dependency using npm. These packages are necessary to interact with Prisma and manage the database schema. ```bash npm install @prisma/client npm install prisma --save-dev ``` -------------------------------- ### Example Python Project Directory Structure Source: https://github.com/aios-labs/projectrules/blob/main/data/rules/manual/pyright.md Illustrates a recommended directory structure for Python projects using the `src` layout, separating application code from tests and configuration files. ```text my_project/ ├── src/ │ ├── my_module/ │ │ ├── __init__.py │ │ ├── file1.py │ │ ├── file2.py │ ├── main.py ├── tests/ │ ├── my_module/ │ │ ├── test_file1.py │ │ ├── test_file2.py │ ├── conftest.py ├── pyrightconfig.json ├── pyproject.toml (or setup.py/setup.cfg) ├── README.md ``` -------------------------------- ### Greenfield Rule Example Input - Markdown/Plain Text Source: https://github.com/aios-labs/projectrules/blob/main/data/rules/manual/greenfield-index.md An example input text that would trigger the 'greenfield-development-index' rule, simulating a user starting a new project and seeking guidance. ```Markdown/Plain Text # Starting a new project I'm starting a new web application and want to follow best practices. ``` -------------------------------- ### Using Prisma in Next.js API Routes (TypeScript) Source: https://github.com/aios-labs/projectrules/blob/main/data/rules/manual/prisma-McCarthyFinch-webinar-project.md Demonstrates how to use the singleton Prisma client instance within Next.js API routes. Includes examples for fetching all notes (GET) and creating a new note (POST) with error handling. ```typescript // app/api/notes/route.ts import { prisma } from '@/lib/prisma' import { NextResponse } from 'next/server' export async function GET() { try { const notes = await prisma.note.findMany({ orderBy: { updatedAt: 'desc', }, }) return NextResponse.json(notes) } catch (error) { return NextResponse.json({ error: 'Failed to fetch notes' }, { status: 500 }) } } export async function POST(request: Request) { try { const { title, content } = await request.json() const note = await prisma.note.create({ data: { title, content, }, }) return NextResponse.json(note, { status: 201 }) } catch (error) { return NextResponse.json({ error: 'Failed to create note' }, { status: 500 }) } } ``` -------------------------------- ### Example Basic Usage (JavaScript) Source: https://github.com/aios-labs/projectrules/blob/main/data/rules/manual/readme-md.md Illustrates a simple example of how to import and use the project package in JavaScript. ```javascript const package = require('package-name'); const result = package.mainFunction(); ``` -------------------------------- ### Installing Specific Shadcn UI Component (Bash) Source: https://github.com/aios-labs/projectrules/blob/main/data/rules/manual/ui-JClackett-modular-synth.md Gives a specific example of using the Shadcn CLI command to install the `accordion` component. This command fetches the component code and adds it to the project's `src/components/ui` directory. ```bash bunx shadcn@latest add accordion ``` -------------------------------- ### Example: User Management System Integration Test Setup Source: https://github.com/aios-labs/projectrules/blob/main/data/rules/manual/3615-integration-testing.md This Python code snippet provides a basic example structure for integration testing. It defines simple `DatabaseService` and `UserService` classes that interact, illustrating the type of components that would be subject to integration tests. It uses `unittest` and `unittest.mock` for potential test implementation. ```python import unittest from unittest.mock import patch, MagicMock # Sample UserService that interacts with a DatabaseService class DatabaseService: def get_user(self, user_id): # Simulates fetching a user from the database pass def save_user(self, user): # Simulates saving a user to the database pass class UserService: def __init__(self, database_service): self.database_service = database_service def get_user_details(self, user_id): user = self.database_service.get_user(user_id) if not user: raise ValueError('User not found') return user def create_user(self, user): if not user.get('name'): raise ValueError('User name is required') self.database_service.save_user(user) ``` -------------------------------- ### Installing the Shadcn Accordion Component via CLI Source: https://github.com/aios-labs/projectrules/blob/main/data/rules/manual/ui-NoQuarterTeam-my-bio-tracker.md Provides a specific example of using the bunx command to add the Accordion component from the shadcn/ui library. ```Bash bunx shadcn@latest add accordion ``` -------------------------------- ### Example requirements.txt File Source: https://github.com/aios-labs/projectrules/blob/main/data/rules/manual/pytorch.md This snippet shows an example of a requirements.txt file, which lists the project's dependencies with specific version constraints. This file is used by package managers like pip to install the necessary libraries. ```requirements.txt torch==1.13.1 torchvision==0.14.1 numpy==1.24.1 ``` -------------------------------- ### Initializing Prisma Project (Bash) Source: https://github.com/aios-labs/projectrules/blob/main/data/rules/manual/prisma-McCarthyFinch-webinar-project.md Initializes Prisma in the project directory. This command creates the `prisma` folder and the essential `schema.prisma` file, which is the core of your Prisma setup. ```bash npx prisma init ``` -------------------------------- ### Example Python Project Directory Structure Source: https://github.com/aios-labs/projectrules/blob/main/data/rules/manual/flake8.md Illustrates a recommended directory structure for Python projects, separating source code, tests, and documentation. It shows the use of packages (`__init__.py`), descriptive naming conventions, and common configuration files like `.flake8` and `pyproject.toml`. ```text my_project/ ├── src/ │ ├── my_package/ │ │ ├── __init__.py │ │ ├── module1.py │ │ ├── module2.py │ ├── another_package/ │ │ ├── __init__.py │ │ ├── ... ├── tests/ │ ├── __init__.py │ ├── test_module1.py │ ├── test_module2.py ├── docs/ │ ├── ... ├── .flake8 ├── pyproject.toml └── README.md ``` -------------------------------- ### Running Basic Ruff Commands (Bash) Source: https://github.com/aios-labs/projectrules/blob/main/data/rules/manual/ruff.md Provides common bash commands using `uv run ruff` to check for linting issues, automatically fix fixable errors, and format code. Includes examples for targeting specific files/directories and a reference to a Makefile target for combined linting and formatting. ```bash # Check linting issues in a file or directory uv run ruff check path/to/file_or_dir # Fix auto-fixable issues uv run ruff check --fix path/to/file_or_dir # Format code using Ruff formatter uv run ruff format path/to/file_or_dir # Automatically fix common issues (like D413 and I001) uv run ruff check --fix --select D413,I001 path/to/file_or_dir # Set up a pre-commit hook to automatically run linting (add to your Makefile or scripts) make lint-fix # Where this runs: uv run ruff check --fix . && uv run ruff format . ``` -------------------------------- ### Deno Configuration Example - JSON Source: https://github.com/aios-labs/projectrules/blob/main/data/rules/manual/deno.md Example configuration for the deno.json file, used to define import maps, linting rules, formatting options, and compiler settings for a Deno project. ```json { "imports": { "*": "./src/", "std/": "https://deno.land/std@0.224.0/" }, "lint": { "rules": { "no-explicit-any": true } }, "fmt": { "lineWidth": 120, "indentWidth": 2 }, "compilerOptions": { "jsx": "react-jsx", "jsxImportSource": "react" } } ``` -------------------------------- ### Vite Project Directory Structure Example Source: https://github.com/aios-labs/projectrules/blob/main/data/rules/manual/vite.md An example directory structure for a Vite project, demonstrating a modular approach based on features and components. ```plaintext src/ ├── components/ │ ├── Button/ │ │ ├── Button.tsx │ │ ├── Button.module.css │ │ └── Button.test.tsx │ ├── Input/ │ │ └── ... ├── pages/ │ ├── Home.tsx │ ├── About.tsx │ └── ... ├── services/ │ ├── api.ts │ └── ... ├── utils/ │ ├── helpers.ts │ └── ... ├── App.tsx ├── main.tsx └── vite-env.d.ts ``` -------------------------------- ### Example Code Example (JavaScript) Source: https://github.com/aios-labs/projectrules/blob/main/data/rules/manual/readme-md.md Provides a sample JavaScript code block demonstrating the recommended format and content for code examples in the README, including comments and usage. ```javascript // Import the package const myPackage = require('my-package'); // Configure options const options = { feature: true, timeout: 1000 }; // Use the package const result = myPackage.doSomething(options); ``` -------------------------------- ### Example TensorFlow Project Directory Structure Source: https://github.com/aios-labs/projectrules/blob/main/data/rules/manual/tensorflow.md Recommended directory structure for organizing a TensorFlow project, separating data, models, source code, notebooks, tests, and configurations into logical folders to improve maintainability and clarity. ```text project_root/ ├── data/ │ ├── raw/ │ └── processed/ ├── models/ │ ├── training/ │ └── saved_models/ ├── src/ │ ├── utils/ │ ├── layers/ │ ├── models/ │ ├── training/ │ └── evaluation/ ├── notebooks/ #Jupyter notebooks for experimentation ├── tests/ ├── configs/ └── README.md ``` -------------------------------- ### Batch Script Visual Feedback Example Source: https://github.com/aios-labs/projectrules/blob/main/data/rules/manual/windows-terminal-guide.md Illustrates how to add visual separators and progress indicators to a batch script to improve readability and provide feedback during execution. ```Batch @echo off echo ======================================== echo Building Shadow Worker (%BUILD_TYPE%) echo ======================================== echo. echo [1/3] Configuring... :: Configuration commands echo [2/3] Building... :: Build commands echo [3/3] Testing... :: Test commands echo ======================================== echo Build completed successfully! echo ======================================== ``` -------------------------------- ### Comprehensive Ruff Configuration in pyproject.toml Source: https://github.com/aios-labs/projectrules/blob/main/data/rules/manual/ruff.md Provides a detailed example of a modern Ruff configuration in pyproject.toml, covering basic settings, include/exclude patterns, linting rules, ignores, and specific tool configurations like McCabe, Pydocstyle, Flake8-type-checking, and isort. ```toml [tool.ruff] # Basic settings target-version = "py312" line-length = 120 # Files to include include = ["*.py", "*.pyi", "*.ipynb"] exclude = [ ".bzr", ".direnv", ".eggs", ".git", ".git-rewrite", ".hg", ".mypy_cache", ".nox", ".pants.d", ".pyenv", ".pytest_cache", ".pytype", ".ruff_cache", ".svn", ".tox", ".venv", ".vscode", "__pypackages__", "_build", "buck-out", "build", "dist", "node_modules", "venv", ] # Allow imports relative to the "src" and "test" directories src = ["src", "tests"] # Allow unused variables when underscore-prefixed dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$" # Linting-specific settings [tool.ruff.lint] select = [ "D", # pydocstyle (PEP257) "E", # pycodestyle errors "F", # pyflakes "UP", # pyupgrade "B", # flake8-bugbear "I", # isort "S", # bandit (security) "YTT", # flake8-2020 "A", # flake8-builtins "C4", # flake8-comprehensions "T10", # flake8-debugger "SIM", # flake8-simplify "C90", # mccabe (complexity) "W", # pycodestyle warnings "PGH", # pygrep-hooks "RUF", # ruff-specific rules ] ignore = [ "B008", # Function calls in default arguments "D417", # Missing argument descriptions in docstrings "E501", # Line too long (handled by formatter) "UP006", # Type annotation format "UP007", # Type annotation format "S101", # Use of assert detected "N812", # Lowercase imported as non-lowercase ] # Allow all rules to be auto-fixed fixable = ["ALL"] unfixable = [] # Maximum McCabe complexity allowed [tool.ruff.lint.mccabe] max-complexity = 10 # Pydocstyle configuration [tool.ruff.lint.pydocstyle] convention = "pep257" # Flake8-type-checking configuration [tool.ruff.lint.flake8-type-checking] runtime-evaluated-decorators = [ "pydantic.computed_field", "pydantic.model_validator" ] # isort settings [tool.ruff.lint.isort] case-sensitive = true force-single-line = false force-sort-within-sections = true known-first-party = ["codegen_lab"] required-imports = ["from __future__ import annotations"] combine-as-imports = true split-on-trailing-comma = false # Define sections for imports sections = [ "future", "standard-library", "third-party", "pytest", "first-party", "local-folder", ] # Define known third-party libraries known-third-party = [ "better_exceptions", "fastapi", "pydantic", "rich", "tenacity", "uvicorn", ] ``` -------------------------------- ### Start Mail Server - Bash Source: https://github.com/aios-labs/projectrules/blob/main/data/rules/manual/readme-stacksjs-ts-maps.md Executes the command to start the configured mail server using the 'post' command-line tool. ```bash post start ``` -------------------------------- ### Initialize SMTP Server - The Post - TypeScript Source: https://github.com/aios-labs/projectrules/blob/main/data/rules/manual/readme-stacksjs-ts-maps.md This TypeScript code shows how to initialize and configure an SMTPServer instance from The Post library. It includes examples for basic setup and advanced configurations like TLS, authentication, message data handling, and custom logging. ```typescript import { SMTPServer } from '@stacksjs/post' // Basic SMTP Server const server = new SMTPServer({ secure: true, name: 'mail.example.com', banner: 'Welcome to My Mail Server', }) server.listen(25) // Advanced Configuration const secureServer = new SMTPServer({ // TLS Configuration secure: true, needsUpgrade: false, sniOptions: new Map([ ['example.com', { key: fs.readFileSync('certs/example.com.key'), cert: fs.readFileSync('certs/example.com.cert') }] ]), // Authentication authMethods: ['PLAIN', 'LOGIN'], onAuth: (auth, session, callback) => { if (auth.username === 'user' && auth.password === 'pass') callback(null, { user: 'user' }) else callback(new Error('Invalid credentials')) }, // Message Handling size: 1024 * 1024, // 1MB limit onData: (stream, session, callback) => { stream.pipe(process.stdout) // Echo message to console stream.on('end', callback) }, // Logging logger: { info: console.log, debug: console.debug, error: console.error } }) secureServer.listen(465) // SMTPS port ``` -------------------------------- ### Define Installation Prerequisites Format (YAML) Source: https://github.com/aios-labs/projectrules/blob/main/data/rules/manual/readme-md.md Outlines the recommended format for listing project prerequisites within the installation section of a README using YAML. ```yaml format: - Tool/dependency name - Version requirements - Installation command - Verification command ``` -------------------------------- ### Install The Post - Bun - Bash Source: https://github.com/aios-labs/projectrules/blob/main/data/rules/manual/readme-stacksjs-ts-maps.md This command demonstrates how to install The Post package using the Bun package manager. The `-d` flag indicates installation as a development dependency. ```bash bun install -d @stacksjs/post ``` -------------------------------- ### Defining Prisma Schema (Prisma) Source: https://github.com/aios-labs/projectrules/blob/main/data/rules/manual/prisma-McCarthyFinch-webinar-project.md Defines the database schema using the Prisma schema language. This includes specifying the database provider (PostgreSQL) and defining models that map to your database tables, like the example `Note` model. ```prisma // This is your Prisma schema file, // learn more about it in the docs: https://pris.ly/d/prisma-schema generator client { provider = "prisma-client-js" } datasource db { provider = "postgresql" url = env("DATABASE_URL") } // Define your models here model Note { id String @id @default(uuid()) title String content String createdAt DateTime @default(now()) updatedAt DateTime @updatedAt } ``` -------------------------------- ### Getting Filtered Scheduled Agent Tasks Source: https://github.com/aios-labs/projectrules/blob/main/data/rules/manual/cloudflare-irvinebroque-agents-starter-braintrust.md Retrieves scheduled tasks that match specific criteria, such as a time range. This example filters for tasks starting within the next hour. ```TypeScript // Filter for specific tasks // e.g. all tasks starting in the next hour let tasks = this.getSchedules({ timeRange: { start: new Date(Date.now()), end: new Date(Date.now() + 60 * 60 * 1000), } }); ``` -------------------------------- ### Get Scheduled Tasks with Filter (Agent) Source: https://github.com/aios-labs/projectrules/blob/main/data/rules/manual/cloudflare-cloudflare-agents.md Retrieves scheduled tasks that match specific criteria, such as a time range. This example filters for tasks starting within the next hour. ```JavaScript let tasks = this.getSchedules({ timeRange: { start: new Date(Date.now()), end: new Date(Date.now() + 60 * 60 * 1000), } }); ``` -------------------------------- ### Using the FAST Web Component in HTML Source: https://github.com/aios-labs/projectrules/blob/main/data/rules/manual/fast-quick-start.md Demonstrates how to include the generated JavaScript file containing the component definition and use the custom `` element in an HTML page, passing an attribute value. ```HTML ``` -------------------------------- ### Basic Starberry Application Example (Rust) Source: https://github.com/aios-labs/projectrules/blob/main/data/rules/manual/starberry.md Demonstrates a complete basic Starberry web application. Includes application initialization, route definitions for the home page, API status, and a dynamic user profile page, using `tokio` for async execution and Starberry's routing and templating features. ```rust use starberry::preload::*; #[tokio::main] async fn main() { APP.clone().run().await; } // Application configuration pub static APP: SApp = Lazy::new(|| { App::new() .binding(String::from("127.0.0.1:3333")) .mode(RunMode::Development) .build() }); // Route handlers #[lit_url(APP, "/")] async fn home_route(_: HttpRequest) -> HttpResponse { akari_render!( "home.html", title="Home Page", message="Welcome to Starberry!" ) } #[lit_url(APP, "/api/status")] async fn api_status(_: HttpRequest) -> HttpResponse { json_response(object!({ status: "ok", version: "1.0", uptime: 3600 })) } // URL tree structure static USER_URL: SUrl = Lazy::new(|| { APP.reg_from(&[LitUrl("users")]) }); #[url(USER_URL.clone(), RegUrl("[0-9]+"))] async fn user_profile(req: HttpRequest) -> HttpResponse { // Get user ID from path let user_id = req.path().split('/').last().unwrap_or("0"); // In a real app, you'd fetch user data from a database akari_render!( "user.html", title="User Profile", user_id=user_id ) } ``` -------------------------------- ### Filter Scheduled Tasks by Time Range Source: https://github.com/aios-labs/projectrules/blob/main/data/rules/manual/cloudflare-jahands-agents-starter-example-test-1.md Retrieves scheduled tasks that are scheduled to start within a specified time range. The example filters for tasks starting within the next hour. ```TypeScript let tasks = this.getSchedules({ timeRange: { start: new Date(Date.now()), end: new Date(Date.now() + 60 * 60 * 1000), } }); ``` -------------------------------- ### Example Cloudflare Worker Configuration (wrangler.jsonc) Source: https://github.com/aios-labs/projectrules/blob/main/data/rules/manual/cloudflare-nicobailon-cloudflare-agent.md An example configuration file for a Cloudflare Worker using wrangler.jsonc, defining the worker name, entry point, compatibility settings, and basic observability. ```JSONC // wrangler.jsonc { "name": "app-name-goes-here", // name of the app "main": "src/index.ts", // default file "compatibility_date": "2025-02-11", "compatibility_flags": ["nodejs_compat"], // Enable Node.js compatibility "observability": { // Enable logging by default "enabled": true, } } ``` -------------------------------- ### Automating Go Build, Run, and Test with Makefile Source: https://github.com/aios-labs/projectrules/blob/main/data/rules/manual/go.md Example Makefile defining common targets for a Go project: `build` compiles the application, `run` executes it, and `test` runs all tests. ```makefile build: go build -o bin/your-application ./cmd/your-application run: go run ./cmd/your-application test: go test ./... ``` -------------------------------- ### Example of Good package.json Configuration (JSON) Source: https://github.com/aios-labs/projectrules/blob/main/data/rules/manual/build-config.md Demonstrates a correct package.json configuration adhering to the rule, specifying exact versions for key dependencies and including the 'pnpm.onlyBuiltDependencies' configuration. ```JSON { "name": "frontend", "version": "0.1.0", "private": true, "type": "module", "scripts": { "dev": "next dev", "build": "next build", "start": "next start", "lint": "next lint", "generate": "npx openapi-typescript-codegen --input ../openapi/main.yaml --output lib/generated --client fetch --name ChatAPI" }, "dependencies": { "next": "15.2.0-canary.67", "react": "19.1.0-canary-fcb4e0f1-20250219", "react-dom": "19.1.0-canary-fcb4e0f1-20250219", "tailwindcss": "^4.0.7" }, "pnpm": { "onlyBuiltDependencies": [ "@nestjs/core", "@prisma/client", "@swc/core" ] } } ``` -------------------------------- ### Defining Installation Rules for Targets and Files (CMake) Source: https://github.com/aios-labs/projectrules/blob/main/data/rules/manual/cmake.md Specifies rules for installing built targets (executables) to the bin directory and header files to the include directory. ```CMake install(TARGETS agent client RUNTIME DESTINATION bin) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/config.h DESTINATION include) ``` -------------------------------- ### Using Starberry CLI - Starberry - Bash Source: https://github.com/aios-labs/projectrules/blob/main/data/rules/manual/starberry.md Lists common command-line interface commands for managing Starberry projects. Includes commands for creating a new project (starberry new), building the project (starberry build), running the application (starberry run), and building for production (starberry release). These commands are executed in the terminal. ```Bash # Create a new project starberry new my_app # Build a project (with template processing) starberry build # Run the application starberry run # Build for production starberry release ``` -------------------------------- ### Good Example of Project Analysis Documentation (Markdown) Source: https://github.com/aios-labs/projectrules/blob/main/data/rules/manual/RESEARCH-project-context.md This snippet provides a good example of how to document project analysis findings using Markdown, showing clear structure, identified components, and specific questions for clarification. ```markdown # Project Analysis: Authentication Service ## Structure - src/ - auth/ - controllers/ - services/ - models/ - config/ - tests/ ## Components 1. Authentication Controller - Handles user authentication - Manages sessions - Rate limiting implemented 2. Database Integration - PostgreSQL for user data - Redis for caching - Clear separation of concerns ## Questions 1. Rate limiting configuration? 2. Session duration policy? [Clear structure, identified components, specific questions] ``` -------------------------------- ### Example SvelteKit Directory Structure Source: https://github.com/aios-labs/projectrules/blob/main/data/rules/manual/sveltekit.md Illustrates a recommended directory structure for a SvelteKit project, organizing components, utilities, stores, routes, server-side logic, hooks, and static assets according to best practices. ```text src/ ├── lib/ │ ├── components/ │ │ ├── Button.svelte │ │ └── Card.svelte │ ├── utils/ │ │ ├── api.ts │ │ └── helpers.ts │ └── stores/ │ └── user.ts ├── routes/ │ ├── +/ │ │ └── page.svelte │ ├── about/ │ │ ├── +/ │ │ │ └── page.svelte │ │ └── +page.server.ts │ └── blog/ │ ├── [slug]/ │ │ ├── +/ │ │ │ └── page.svelte │ │ └── +page.server.ts │ └── +/ │ └── page.svelte ├── hooks.server.ts └── app.d.ts ``` -------------------------------- ### Example of Monolithic Service (Bad Practice) (Python) Source: https://github.com/aios-labs/projectrules/blob/main/data/rules/manual/service-oriented-architecture.md This Python class is presented as a negative example of a monolithic service. It demonstrates how combining unrelated responsibilities (getting customer data and processing requests) within a single class violates the Single Responsibility Principle, which is a core tenet of good service-oriented architecture. ```Python class SmartHomeService: def __init__(self, db_client): self.db_client = db_client def get_customer(self, customer_id): return self.db_client.get_item(table="customers", key={"id": customer_id}) def process_request(self, customer_id, request_text): customer = self.get_customer(customer_id) ``` -------------------------------- ### Example mkdocs Project Directory Structure Source: https://github.com/aios-labs/projectrules/blob/main/data/rules/manual/mkdocs.md Illustrates the recommended directory layout for an mkdocs project, showing the placement of the main configuration file, documentation source files, images, and subdirectories for organizing content. ```Text mkdocs.yml docs/ index.md about.md license.md img/ screenshot.png user-guide/ getting-started.md configuration-options.md ``` -------------------------------- ### Installing PostgreSQL Driver for TypeORM Source: https://github.com/aios-labs/projectrules/blob/main/data/rules/manual/db.md Provides the shell command required to install the necessary npm package ('pg') for enabling PostgreSQL database connectivity with TypeORM. ```Shell npm install pg --save ``` -------------------------------- ### Creating Initial Database Migration (Bash) Source: https://github.com/aios-labs/projectrules/blob/main/data/rules/manual/prisma-McCarthyFinch-webinar-project.md Creates and applies the first database migration based on the initial schema definition. The `--name init` flag provides a descriptive name for this migration. ```bash npx prisma migrate dev --name init ``` -------------------------------- ### Organizing Modules with JavaScript Source: https://github.com/aios-labs/projectrules/blob/main/data/rules/manual/webpack.md Demonstrates how to structure JavaScript modules by functionality, providing examples of utility functions like fetchData and formatDate. This promotes code reusability and maintainability. ```javascript // src/modules/api.js export function fetchData(url) { // ... } // src/modules/utils.js export function formatDate(date) { // ... } ``` -------------------------------- ### Example README Update for IDE Domain (Markdown) Source: https://github.com/aios-labs/projectrules/blob/main/data/rules/manual/update-markdown-nested-lists.md Shows the updated content of the `prompts/domains/ide/README.md` file after adding a new test example, demonstrating how to include a link to the new file under the relevant section. ```markdown # IDE Domain ## Contents - [Testing](./testing/README.md) - [Test Example](./testing/test-example.md) ``` -------------------------------- ### Starting Mail Server with post command Source: https://github.com/aios-labs/projectrules/blob/main/data/rules/manual/readme-stacksjs-post.md This command is used to start the Mail Server after the configuration file has been set up. It initiates the server process based on the provided configuration. ```Bash post start ``` -------------------------------- ### Defining a Matrix for FFT Examples (FreeMat) Source: https://github.com/aios-labs/projectrules/blob/main/data/rules/manual/fft.md Initializes a 2x2 matrix `A` to be used in subsequent examples demonstrating FFT computation along different dimensions. ```FreeMat A = [2,5;3,6] ``` -------------------------------- ### Adjust Tooltip Positioning Behavior - JavaScript Source: https://github.com/aios-labs/projectrules/blob/main/data/rules/manual/creating-tooltips.md Provides an example of modifying the offset from the cursor and padding from viewport edges within the updateTooltipPosition function to change the tooltip's placement behavior. ```javascript function updateTooltipPosition(e) { const offset = 10; // Smaller offset from cursor const padding = 30; // Larger padding from viewport edges // ...rest of function } ``` -------------------------------- ### Example .mdc Frontmatter (YAML) Source: https://github.com/aios-labs/projectrules/blob/main/data/rules/manual/mdc.md This snippet shows a typical example of the frontmatter section required at the beginning of an .mdc file. It includes essential metadata like description, file globs, and optional related documentation references. ```yaml --- description: Guidelines for implementing feature X globs: ["**/*.{ts,tsx}"] related_docs: ["docs/architecture/feature-x.md"] --- ``` -------------------------------- ### Greenfield Rule Example Output - Plain Text Source: https://github.com/aios-labs/projectrules/blob/main/data/rules/manual/greenfield-index.md The expected output message from the 'greenfield-development-index' rule when the example input is provided, suggesting the user reference the relevant workflow rules. ```Plain Text Reference the Greenfield development workflow rules for guidance ``` -------------------------------- ### Installing Additional Shadcn UI Components (Bash) Source: https://github.com/aios-labs/projectrules/blob/main/data/rules/manual/ui-JClackett-modular-synth.md Provides the general command-line interface (CLI) instruction using `bunx` to add new Shadcn UI components to the project. The placeholder `[component-name]` should be replaced with the name of the component to be installed. ```bash bunx shadcn@latest add [component-name] ``` -------------------------------- ### Example Python Project Directory Structure Source: https://github.com/aios-labs/projectrules/blob/main/data/rules/manual/numba.md Illustrates a recommended directory structure for a Python project utilizing Numba, separating source code, tests, examples, documentation, benchmarks, and development scripts. ```text my_project/ ├── src/ │ ├── __init__.py │ ├── core/ │ │ ├── __init__.py │ │ ├── functions.py │ │ ├── types.py │ ├── cuda/ │ │ ├── __init__.py │ │ ├── kernels.py │ │ ├── device.py │ ├── npyimpl/ │ │ ├── __init__.py │ │ ├── array_methods.py │ │ ├── reductions.py ├── tests/ │ ├── __init__.py │ ├── core/ │ │ ├── test_functions.py │ │ ├── test_types.py │ ├── cuda/ │ │ ├── test_kernels.py │ │ ├── test_device.py │ ├── npyimpl/ │ │ ├── test_array_methods.py │ │ ├── test_reductions.py ├── examples/ │ ├── mandelbrot.py │ ├── gaussian_blur.ipynb ├── docs/ │ ├── source/ │ │ ├── conf.py │ │ ├── index.rst │ ├── Makefile ├── benchmarks/ │ ├── bench_matmul.py ├── scripts/ │ ├── build_extensions.py ├── .cursor/ │ ├── rules/ │ │ ├── numba_rules.mdc ├── setup.py ├── README.md ├── LICENSE ``` -------------------------------- ### NeuroLens DSL: Example Workflow Input (Python) Source: https://github.com/aios-labs/projectrules/blob/main/data/rules/manual/neurolens-styles-rules.md Presents a complete example of NeuroLens DSL generated by an LLM from a natural language request, demonstrating the combination of layout, typography, colors, and interaction styles. ```Python c dir=col align=c pad=32 bg=#1a237e h1 t="NeuroLens" s=36 tc=white p t="AI-driven UI framework." s=16 tc=#eee btn t=Try bg=#2196f3 tc=white pad=12 br=4 @hover bg=#9c27b0 ``` -------------------------------- ### Rules Section Example (Markdown) Source: https://github.com/aios-labs/projectrules/blob/main/data/rules/manual/mdc.md Provides an example of the @rules annotation structure within an MDC file, showing the required properties (id, severity, description) for each rule entry. ```markdown @rules [ { "id": "unique_identifier", "severity": "error|warning|info", "description": "Clear description of the rule" } ] ``` -------------------------------- ### Filtering Scheduled Agent Tasks Source: https://github.com/aios-labs/projectrules/blob/main/data/rules/manual/cloudflare-nicobailon-cloudflare-agent.md Shows how to retrieve a subset of scheduled tasks based on criteria like time range. This example filters for tasks scheduled to start within the next hour. ```TypeScript // Filter for specific tasks // e.g. all tasks starting in the next hour let tasks = this.getSchedules({ timeRange: { start: new Date(Date.now()), end: new Date(Date.now() + 60 * 60 * 1000), } }); ``` -------------------------------- ### Containerizing Go Application with Dockerfile Source: https://github.com/aios-labs/projectrules/blob/main/data/rules/manual/go.md Multi-stage Dockerfile to build and package a Go application. The first stage builds the binary, and the second stage creates a minimal image containing only the executable. ```dockerfile FROM golang:1.21-alpine AS builder WORKDIR /app COPY go.mod go.sum ./ RUN go mod download COPY . . RUN go build -o /bin/your-application ./cmd/your-application FROM alpine:latest WORKDIR /app COPY --from=builder /bin/your-application . CMD ["./your-application"] ``` -------------------------------- ### Prohibited Pattern: Unix Pipe to Cat in Batch Script Source: https://github.com/aios-labs/projectrules/blob/main/data/rules/manual/windows-terminal-guide.md Example of a strictly forbidden pattern: piping output to the `cat` command, which is not native to Windows and has no meaningful effect. ```Batch Scripting type file.txt | cat ``` -------------------------------- ### Example 1: Simple Augmented Agent Source: https://github.com/aios-labs/projectrules/blob/main/data/rules/manual/Building_Effective_Agents.rules.md Sample prompt for Cursor Composer (or Chat) demonstrating how to build a simple effective agent using an augmented LLM, including context retrieval, tool calls, and response synthesis. This prompt helps verify that the agent design guidelines are followed. ```Prompt [Cursor Rule] Build a simple effective agent that uses an augmented LLM. The agent should first retrieve context using Context Shepherd, then call a tool to perform a minor task (e.g., data retrieval), and finally combine the results in a clear, concise response. ``` -------------------------------- ### Hyperdrive Postgres - Usage (Shell) Source: https://github.com/aios-labs/projectrules/blob/main/data/rules/manual/cloudflare-irvinebroque-agents-starter-braintrust.md Command-line instructions for setting up the Hyperdrive example. Includes installing the `postgres` npm package and creating a Hyperdrive configuration using `wrangler hyperdrive create` with the database connection string. ```shell // Install Postgres.js npm install postgres // Create a Hyperdrive configuration npx wrangler hyperdrive create --connection-string="postgres://user:password@HOSTNAME_OR_IP_ADDRESS:PORT/database_name" ``` -------------------------------- ### Example mkdocs.yml Navigation Configuration Source: https://github.com/aios-labs/projectrules/blob/main/data/rules/manual/mkdocs.md Demonstrates how to define the site's navigation menu structure in the mkdocs.yml file, mapping menu items to specific Markdown files and organizing them hierarchically. ```YAML nav: - Home: index.md - User Guide: - Getting Started: user-guide/getting-started.md - Configuration Options: user-guide/configuration-options.md - About: about.md - License: license.md ``` -------------------------------- ### Creating a FAST Web Component in TypeScript Source: https://github.com/aios-labs/projectrules/blob/main/data/rules/manual/fast-quick-start.md Defines a custom web component `` using `@microsoft/fast-element`. It includes defining the HTML template, CSS styles, component logic with an attribute, and registering the component with the browser. ```TypeScript import { attr, css, FASTElement, html } from "@microsoft/fast-element"; /** * Create an HTML template using the html tag template literal, * this contains interpolated text content from a passed attribute */ const template = html`Hello ${x => x.name}!`; /** * Create CSS styles using the css tag template literal */ const styles = css` :host { border: 1px solid blue; } span { color: red; } `; /** * Define your component logic by creating a class that extends * the FASTElement, note the addition of the attr decorator, * this creates an attribute on your component which can be passed. */ class HelloWorld extends FASTElement { @attr name: string; } /** * Define your custom web component for the browser, as soon as the file * containing this logic is imported, the element "hello-world" will be * defined in the DOM with it's html, styles, logic, and tag name. */ HelloWorld.define({ name: "hello-world", template, styles, }); ``` -------------------------------- ### Example: Data Processing with Comments (Python) Source: https://github.com/aios-labs/projectrules/blob/main/data/rules/manual/130-commenting-standards.md This Python snippet demonstrates the initial structure for data processing, including defining a custom exception and the start of a processing function. It illustrates the use of comments to explain the purpose of classes and functions. ```python import json from typing import List, Dict, Any, Union # Define a custom exception for handling data processing errors. class DataProcessingError(Exception): pass # Function to process a list of data entries and return a summary report. ``` -------------------------------- ### Loading JavaScript Modules On-Demand with jQuery Source: https://github.com/aios-labs/projectrules/blob/main/data/rules/manual/jquery.md Provides an example of code splitting by demonstrating how to load an external JavaScript file (heavyModule.js) dynamically using jQuery's $.getScript function when a button is clicked. ```javascript // Example: Loading a module on button click $('#load-module-button').on('click', function() { $.getScript('js/modules/heavyModule.js', function() { // Module loaded and executed heavyModule.init(); }); }); ``` -------------------------------- ### Initializing Server with Functional Options in Go Source: https://github.com/aios-labs/projectrules/blob/main/data/rules/manual/go.md This snippet shows a pattern for initializing a server struct, likely using functional options passed as arguments to the constructor function `NewServer`. It iterates through the options to configure the server instance. ```Go Port: 8080, Protocol: "tcp", Timeout: 30 * time.Second, } for _, option := range options { option(srv) } return srv } // Usage server := NewServer(WithAddress("127.0.0.1"), WithPort(9000)) ``` -------------------------------- ### Running Development Server - Bash Source: https://github.com/aios-labs/projectrules/blob/main/README.md This snippet shows how to start the local development server for the project using different Node.js package managers. It provides options for npm, yarn, pnpm, and bun. ```bash npm run dev # or yarn dev # or pnpm dev # or bun dev ``` -------------------------------- ### Implementing Distributed Tracing in Go Handlers Source: https://github.com/aios-labs/projectrules/blob/main/data/rules/manual/monitoring-rules.md This example shows how to create and manage spans within an OpenTelemetry trace in a Go handler. It starts a new span, adds relevant attributes, records errors, and sets the span status. ```Go // handler/order.go func (h *Handler) ProcessOrder(w http.ResponseWriter, r *http.Request) { ctx := r.Context() tracer := otel.Tracer("order-service") ctx, span := tracer.Start(ctx, "ProcessOrder") defer span.End() // Add relevant attributes span.SetAttributes( attribute.String("order.id", orderID), attribute.Float64("order.amount", amount), ) // Process order with context err := h.orderService.Process(ctx, order) if err != nil { span.RecordError(err) span.SetStatus(codes.Error, err.Error()) // ... error handling } } ``` -------------------------------- ### Defining Bonus Transaction List Method (TypeScript) Source: https://github.com/aios-labs/projectrules/blob/main/data/rules/manual/jsdoc.md This snippet shows a TypeScript interface `BonusTransactionEndpoint` and specifically documents its `list` method using JSDoc. The documentation explains the method's purpose (fetching bonus transactions) and uses `@param`, `@returns`, `@see`, and `@example` tags to provide details on parameters, return value, related documentation, and usage examples. It also demonstrates linking to other code symbols using `{@linkcode SymbolName}`. ```TypeScript /** * Бонусные операции * * @see https://dev.moysklad.ru/doc/api/remap/1.2/dictionaries/#suschnosti-bonusnaq-operaciq-bonusnye-operacii */ export interface BonusTransactionEndpoint { /** * Получить список бонусных операций. * * @param options - Опции для получения списка {@linkcode ListBonusTransactionsOptions} * @returns Объект с списком бонусных операций * * @see https://dev.moysklad.ru/doc/api/remap/1.2/dictionaries/#suschnosti-bonusnaq-operaciq-poluchit-bonusnye-operacii * * @example * ```ts * const { rows } = await moysklad.bonusTransaction.list(); * ``` */ list>( options?: Subset, ): Promise< ListResponse< GetFindResult, Entity.BonusTransaction > >; } ``` -------------------------------- ### Organizing Tests with unittest.TestCase in Python Source: https://github.com/aios-labs/projectrules/blob/main/data/rules/manual/nose2.md Demonstrates how to structure tests within a Python module using `unittest.TestCase`. It shows the use of `setUp` and `tearDown` methods for test fixtures and defines individual test methods starting with `test_`. ```python # tests/test_user.py import unittest from myapp import user class TestUser(unittest.TestCase): def setUp(self): # Setup code to run before each test self.user = user.User("testuser", "password") def tearDown(self): # Teardown code to run after each test pass def test_user_creation(self): self.assertEqual(self.user.username, "testuser") self.assertTrue(self.user.check_password("password")) def test_invalid_password(self): self.assertFalse(self.user.check_password("wrong_password")) ``` -------------------------------- ### Example Kubernetes Project Directory Structure Source: https://github.com/aios-labs/projectrules/blob/main/data/rules/manual/kubernetes.md Illustrates a recommended directory structure for a Kubernetes project, separating concerns into standard directories like cmd/, pkg/, internal/, config/, and scripts/. ```Text my-kubernetes-project/ ├── cmd/ │ └── controller/ │ └── main.go ├── pkg/ │ └── api/ │ ├── types.go │ └── controller/ │ ├── controller.go │ ├── reconciler.go │ └── util/ │ └── util.go ├── internal/ │ └── admission/ │ └── webhook.go ├── config/ │ ├── deploy/ │ │ └── deployment.yaml │ └── kustomize/ │ ├── base/ │ │ ├── kustomization.yaml │ │ └── ... │ └── overlays/ │ ├── dev/ │ │ ├── kustomization.yaml │ │ └── ... │ └── prod/ │ ├── kustomization.yaml │ └── ... ├── scripts/ │ └── build.sh ├── docs/ │ └── architecture.md └── go.mod ``` -------------------------------- ### Batch Script Input Validation Example Source: https://github.com/aios-labs/projectrules/blob/main/data/rules/manual/windows-terminal-guide.md Demonstrates how to validate command-line input parameters in a batch script, checking if the provided build type is either 'Debug' or 'Release' and providing an error message if invalid. ```Batch @echo off setlocal EnableDelayedExpansion :: Validate build type set "BUILD_TYPE=%1" if "%BUILD_TYPE%"=="" set "BUILD_TYPE=Debug" if not "%BUILD_TYPE%"=="Debug" if not "%BUILD_TYPE%"=="Release" ( echo Invalid build type: %BUILD_TYPE% echo Valid options: Debug, Release exit /b 1 ) ``` -------------------------------- ### Standard Batch Script Header Source: https://github.com/aios-labs/projectrules/blob/main/data/rules/manual/windows-terminal-guide.md Provides a template for a standard batch script header, including turning off echo, enabling delayed expansion, and documenting the script's name, purpose, usage, and an example. ```Batch @echo off setlocal EnableDelayedExpansion :: Script: build_project.bat :: Purpose: Builds the Shadow Worker project :: Usage: build_project.bat [Debug|Release] [clean] :: :: Example: build_project.bat Debug clean ``` -------------------------------- ### Prohibited Pattern: Unix mkdir -p in Batch Script Source: https://github.com/aios-labs/projectrules/blob/main/data/rules/manual/windows-terminal-guide.md Example of a strictly forbidden pattern: using the Unix-style `mkdir -p` command, which is incompatible with Windows command processors and can cause errors. ```Batch Scripting mkdir -p some/nested/dir ```