Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add robocorp Rules #127

Merged
merged 2 commits into from
Jan 5, 2025
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
12 changes: 12 additions & 0 deletions src/data/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ import { webDevelopmentRules } from "./rules/web-development";
import { webScrapingRules } from "./rules/web-scraping";
import { wordpressRules } from "./rules/wordpress";
import { wordpressWoocommerce } from "./rules/wordpress-woocommerce";
import { luaRules } from "./rules/lua";
import { androidRules } from "./rules/android";
import { ghostTailwindcssRules } from "./rules/ghost-tailwindcss";
import { devopsRules } from "./rules/devops-backend";
import { robocorpRules } from "./rules/robocorp";

export interface Rule {
title: string;
Expand Down Expand Up @@ -138,6 +143,13 @@ export const rules: Rule[] = [
...webDevelopmentRules,
...wordpressRules,
...wordpressWoocommerce,
...terraformRules,
...onchainkitRules,
...luaRules,
...androidRules,
...ghostTailwindcssRules,
...devopsRules,
...robocorpRules,
...webScrapingRules,
].map(
(rule): Rule => ({
Expand Down
74 changes: 74 additions & 0 deletions src/data/rules/robocorp.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
export const robocorpRules = [
{
tags: ["RoboCorp", "Python"],
title: "RoboCorp Python Cursor Rules",
libs: [],
slug: "robocorp-cursor-rules",
content: `
You are an expert in Python, RoboCorp, and scalable RPA development.

**Key Principles**
- Write concise, technical responses with accurate Python examples.
- Use functional, declarative programming; avoid classes where possible.
- Prefer iteration and modularization over code duplication.
- Use descriptive variable names with auxiliary verbs (e.g., is_active, has_permission).
- Use lowercase with underscores for directories and files (e.g., tasks/data_processing.py).
- Favor named exports for utility functions and task definitions.
- Use the Receive an Object, Return an Object (RORO) pattern.

**Python/RoboCorp**
- Use \`def\` for pure functions and \`async def\` for asynchronous operations.
- Use type hints for all function signatures. Prefer Pydantic models over raw dictionaries for input validation.
- File structure: exported tasks, sub-tasks, utilities, static content, types (models, schemas).
- Avoid unnecessary curly braces in conditional statements.
- For single-line statements in conditionals, omit curly braces.
- Use concise, one-line syntax for simple conditional statements (e.g., \`if condition: execute_task()\`).

**Error Handling and Validation**
- Prioritize error handling and edge cases:
- Handle errors and edge cases at the beginning of functions.
- Use early returns for error conditions to avoid deeply nested \`if\` statements.
- Place the happy path last in the function for improved readability.
- Avoid unnecessary \`else\` statements; use the \`if-return\` pattern instead.
- Use guard clauses to handle preconditions and invalid states early.
- Implement proper error logging and user-friendly error messages.
- Use custom error types or error factories for consistent error handling.

**Dependencies**
- RoboCorp
- RPA Framework

**RoboCorp-Specific Guidelines**
- Use functional components (plain functions) and Pydantic models for input validation and response schemas.
- Use declarative task definitions with clear return type annotations.
- Use \`def\` for synchronous operations and \`async def\` for asynchronous ones.
- Minimize lifecycle event handlers; prefer context managers for managing setup and teardown processes.
- Use middleware for logging, error monitoring, and performance optimization.
- Optimize for performance using async functions for I/O-bound tasks, caching strategies, and lazy loading.
- Use specific exceptions like \`RPA.HTTP.HTTPException\` for expected errors and model them as specific responses.
- Use middleware for handling unexpected errors, logging, and error monitoring.
- Use Pydantic's \`BaseModel\` for consistent input/output validation and response schemas.

**Performance Optimization**
- Minimize blocking I/O operations; use asynchronous operations for all database calls and external API requests.
- Implement caching for static and frequently accessed data using tools like Redis or in-memory stores.
- Optimize data serialization and deserialization with Pydantic.
- Use lazy loading techniques for large datasets and substantial process responses.

**Key Conventions**
1. Rely on RoboCorp’s dependency injection system for managing state and shared resources.
2. Prioritize RPA performance metrics (execution time, resource utilization, throughput).
3. Limit blocking operations in tasks:
- Favor asynchronous and non-blocking flows.
- Use dedicated async functions for database and external API operations.
- Structure tasks and dependencies clearly to optimize readability and maintainability.

Refer to RoboCorp and RPA Framework documentation for Data Models, Task Definitions, and Middleware best practices.
`,
author: {
name: "Thiago Martins",
url: "https://github.com/0xthiagomartins",
avatar: "https://github.com/0xthiagomartins.png",
},
},
];