agentleFS
learnwithcclearnwithcc/tally-mcp/.cursor/rules/long_running_tasks.mdc

tally-mcp / rules

Cursor rule8 starsChanged 17 months agoISCArchived repositoryView on GitHub

To avoid connection failed or timeout errors during long-running operations like performance tests, builds, or complex tool calls, follow these guidelines. By following these strategies, we can work more effectively within Cursor's constraints, leading to more productive and less interrupted development sessions.

  • Where files are headingNew Cursor rule files have more rules about planning and tracking tasks, and fewer about code style.

    Of the Cursor rule files we read, the 4,183 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.

  • In this repository4 other files it gives its agents.

The file

We split this long_running_tasks.mdc into the rules it gives an agent

6 rules. About 0 are common, 3 are distinctive, and 3 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈3

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 3

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Example (Artillery): Instead of one long test, run multiple short tests targeting specific phases or scenarios.

    line 19
  2. Very specific:

    Kill Previous Processes: Before starting a new instance of a server or long-running task, always ensure the previous one is terminated to …

    line 21
  3. Very specific:

    Command: Use kill $(lsof -t -i:<port>) 2>/dev/null || true to gracefully kill any process on a given port.

    line 22
  4. Distinctive:

    Example (Artillery): Instead of running a full 10-minute test suite, run a single, short scenario first to verify configuration.

    line 31
  5. Very specific:

    Example (Builds/Tests): Instead of running npm test, run tests for a specific file or component: jest src/components/MyComponent.test.ts.

    line 43
  6. Distinctive:

    Follow-up: After starting a background task, subsequent steps should involve checking its output (e.g., via log files) or status, rather …

    line 49

≈ “Common” is an estimate: at least 1 in 5 of the 6,668 Cursor rule files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
long_running_tasks.mdc
---
description: 
globs: 
alwaysApply: false
---
# Handling Long-Running Processes in Cursor

To avoid `connection failed` or timeout errors during long-running operations like performance tests, builds, or complex tool calls, follow these guidelines.

## 1. Acknowledge Cursor's Timeout Limits

-   **Fixed Timeouts:** Cursor imposes a non-configurable timeout on tool calls and other background processes initiated from chat. This can be as short as 5 seconds.
-   **No User Control:** There is currently no setting to extend this timeout.

## 2. Best Practices for Long-Running Tasks

-   **Break Down Tasks:** Sub-divide long processes into smaller chunks.
    -   **Target Duration:** Aim for each chunk to complete in **under 5 seconds** to be safe.
    -   **Example (Artillery):** Instead of one long test, run multiple short tests targeting specific phases or scenarios.

-   **Kill Previous Processes:** Before starting a new instance of a server or long-running task, always ensure the previous one is terminated to avoid port conflicts (`EADDRINUSE`).
    -   **Command:** Use `kill $(lsof -t -i:<port>) 2>/dev/null || true` to gracefully kill any process on a given port.

-   **Execute Externally (If Necessary):** For tasks that cannot be broken down (e.g., a full production build), the best practice is to run them in a separate, dedicated terminal outside of the agent's control and then report the results back.

-   **Provide Feedback:** Continue to report when timeouts occur, as this helps refine our internal best practices and provides data for potential future feature requests to the Cursor team.

## 3. Primary Strategy: Decompose and Conquer

-   **Break Down Tasks:** The most effective strategy is to break down long-running commands into smaller, incremental steps that can each complete within the timeout window.
-   **Example (Artillery):** Instead of running a full 10-minute test suite, run a single, short scenario first to verify configuration. Then, run shorter phases of the test separately.
    ```bash
    # Instead of this:
    npx artillery run long-test-suite.yml

    # Do this:
    # Step 1: Verify a single scenario
    npx artillery run --scenario "Quick Smoke Test" test-suite.yml

    # Step 2: Run a shorter phase
    npx artillery run --phase "Warm-up" test-suite.yml
    ```
-   **Example (Builds/Tests):** Instead of running `npm test`, run tests for a specific file or component: `jest src/components/MyComponent.test.ts`.

## 4. Use Background Execution Strategically

-   **Background for Independence:** For tasks that *must* run for a long time, use the `is_background: true` flag in the `run_terminal_cmd` tool.
-   **Fire-and-Forget:** Understand that when a task is backgrounded, the agent may not get a direct success/failure result if the connection times out. The process will continue running on the user's machine, but the agent loses its direct handle on it.
-   **Follow-up:** After starting a background task, subsequent steps should involve checking its output (e.g., via log files) or status, rather than assuming it completed successfully.

## 5. Artillery-Specific Considerations

-   **Internal vs. External Timeouts:** Remember that Artillery's own HTTP request timeout (`config.http.timeout`) is separate from Cursor's process execution timeout. Increasing Artillery's timeout will not prevent Cursor from terminating the process.

By following these strategies, we can work more effectively within Cursor's constraints, leading to more productive and less interrupted development sessions.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.