Skip to content
The Chat Archive
gemini-2.5-pro-exp-03-25-grounding· Google LMArena Search Arena 24K

find me the best and mostly used rules to put into the global rules of a ai coding agent…

  1. User

    find me the best and mostly used rules to put into the global rules of a ai coding agent for best and safe project building.

  2. Assistant

    Okay, let's find some core principles and rules that are widely applicable and crucial for guiding an AI coding agent towards building safe, reliable, and maintainable projects. These global rules act as foundational directives.

    Based on the search results and general best practices in software engineering, here are some of the most important and commonly used rules to put into the "global rules" or system prompt for an AI coding agent, focusing on safe and high-quality project building:

    Core Principles:

    1. Human Oversight is Mandatory: Explicitly state that all AI-generated code must be reviewed, tested, and validated by a human developer before integration or deployment. AI is an assistant, not the final authority. [1, 5, 8, 10, 11, 12, 16][[3]][[4]][[7]]
    2. Prioritize Security Above All: Security is paramount. Follow secure coding practices diligently.[[10]] When in doubt, choose the more secure approach. [1, 2, 6, 10, 12, 15, 18][[3]][[4]][[7]]
    3. Adhere to Project Context and Standards: Always consider the specific project's requirements, existing codebase style, chosen frameworks, and established coding standards (e.g., PEP 8 for Python, language-specific guidelines). [3, 14, 15, 17][[3]][[4]][[7]]
    4. Clarity and Maintainability: Write code that is clear, readable, well-documented, and easy for humans to understand and maintain. [9, 14, 17, 19][[3]][[4]][[7]]
    5. Robustness and Reliability: Aim for code that handles errors gracefully, considers edge cases, and is thoroughly tested. [2, 5, 15, 19][[3]][[4]][[7]]

    Specific Global Rules (Examples):

    • Security & Safety:

      • Sanitize Inputs: Always sanitize and validate all external inputs (user inputs, API responses, file contents, environment variables) to prevent injection attacks (SQLi, XSS, etc.). Use established libraries/frameworks for this (e.g., OWASP ESAPI). [1]
      • Secrets Management: Never hardcode secrets (API keys, passwords, tokens). Use environment variables, dedicated secrets management tools (like HashiCorp Vault, AWS Secrets Manager), or configuration files outside the codebase. [1, 7]
      • Secure Dependencies: Use only well-maintained, trusted libraries. Verify dependencies for known vulnerabilities (use tools like OWASP Dependency-Check, Dependabot) and keep them updated. [7, 12, 18][[3]][[4]][[7]]
      • Principle of Least Privilege: Grant only the minimum necessary permissions for any operation or component. [2]
      • Secure Defaults: Ensure default configurations are secure (e.g., disable debug modes in production, use HTTPS). [1]
      • Authentication & Authorization: Implement strong, standard authentication (e.g., MFA, OAuth 2.[[10]]0) and authorization checks. [1]
      • Error Handling Security: Avoid revealing sensitive information (stack traces, system details) in error messages exposed to users. Log details securely.
      • Ethical Boundaries: Do not generate malicious, unethical, discriminatory, or harmful code. Respect data privacy regulations. [5, 21][[3]][[4]][[7]]
    • Code Quality & Readability:

      • Follow Style Guides: Strictly adhere to the specified language style guide (e.g., "Follow PEP 8 for Python," "Follow Google Java Style Guide"). [14, 17, 19][[3]][[4]][[7]]
      • Meaningful Naming: Use clear, descriptive names for variables, functions, classes, etc. [17]
      • DRY Principle (Don't Repeat Yourself): Avoid code duplication. Use functions, classes, or modules to encapsulate reusable logic. [14]
      • Keep it Simple & Focused (SRP): Functions/methods/classes should be small, focused on a single responsibility, and easy to understand. Avoid overly complex logic in one place. [17, 19][[3]][[4]][[7]]
      • Modern Idioms: Prefer modern, idiomatic language features and patterns where appropriate and supported by the project's standards. [14, 17][[3]][[4]][[7]]
    • Robustness & Testing:

      • Comprehensive Error Handling: Implement explicit error handling (e.g., try-except blocks, checking return values). Handle specific error types rather than generic exceptions where possible. [17]
      • Write Tests: Generate unit tests (and potentially integration tests) covering core functionality, edge cases, and error conditions for any non-trivial code produced. Aim for testable code. [5, 9, 18, 19][[3]][[4]][[7]]
      • Logging: Implement clear and informative logging for significant events, errors, and debugging purposes.
    • Maintainability & Documentation:

      • Add Comments & Documentation: Comment non-obvious logic ("why," not just "what"). Generate docstrings/Javadoc/equivalent for public APIs, functions, and classes. Keep documentation updated. [17, 19, 23][[3]][[4]][[7]]
      • Modularity: Structure code logically into modules, classes, or packages.
    • Interaction & Process:

      • Be Specific: Provide clear, detailed instructions and context for requests. [4, 19][[3]][[4]][[7]]
      • Iterative Refinement: Be prepared to iterate.[[5]] Refine prompts based on previous outputs. Ask clarifying questions if the request is ambiguous. [9, 11, 16][[3]][[4]][[7]]
      • Use Provided Context: Leverage project files, existing code, and documentation provided as context to ensure consistency. [14, 24]
      • Transparency: If generating code based on external sources or potentially licensed material, note this. [2, 13][[3]][[4]][[7]]

    Important Considerations:

    • Customization: These are general rules. You'll need to tailor them based on the specific programming languages, frameworks, project requirements, and team standards. [3, 17][[3]][[4]][[7]]
    • Tool Capabilities: The effectiveness depends on the AI agent's ability to understand and follow these rules. Some tools allow formalizing these rules in configuration files.[[13]] [14, 17, 19][[3]][[4]][[7]]
    • Continuous Improvement: Regularly review and update these global rules as best practices evolve and you learn more about interacting effectively with your specific AI agent. [5, 18][[3]][[4]][[7]]
    • Limitations: Remember that AI models are trained on vast datasets which may include outdated or insecure code.[[10]] They don't truly "understand" context or security implications like a human expert. [1, 6, 9, 15][[3]][[4]][[7]]

    By establishing strong global rules, you guide the AI towards generating code that is more likely to be secure, reliable, and maintainable, significantly improving the safety and quality of the projects it contributes to. However, diligent human review remains essential.[[14]] [1, 5, 8, 12][[3]][[4]][[7]]

  3. User

    I am trying this new trend that is called VIBE CODING with AI. I want you to find me the best and majority agreed list of steps that are most useful and crucial for successfully creating a website/web app or any coding project. Put everything in a simple .md format and everything should be in a format that I can feed into the AI CODING AGENT to get the desired output out of it. Example: "1. Setting up global and project rules in which there will be best practices for coding and security of app and fast and proper functionality of app and all the rules that should be there to avoid any stupid and freaky ai coding agent errors for the agentic ai so it won't get off track while creating the project. 1. create a Product Requirements Document - PRD.md file 2. create a tasks.md file according to the PRD.md file 3. ... 4. ... 5. ..."

  4. Assistant

    Okay, here is a set of steps formatted in simple markdown (.md) suitable for guiding an AI coding agent through a "Vibe Coding" process for building a web project. This workflow incorporates standard best practices while allowing for the flexibility implied by "Vibe Coding," emphasizing iteration and human oversight.

    # Vibe Coding Project Workflow with AI Agent
    
    **Goal:** To guide an AI coding agent in building a [Specify Project Type - e.g., website, web application] based on a core "vibe" or concept, emphasizing iteration, best practices, and human oversight.
    
    **Instructions for AI Agent:** Follow these steps sequentially. Human oversight, review, and refinement are required at *each* step.
    
    ---
    
    **Phase 1: Foundation & Setup**
    
    1.  **Establish Global Rules:**
        *   Load and strictly adhere to the predefined `GLOBAL_RULES.md`. This file contains essential rules for security (input sanitization, secrets management, secure dependencies, least privilege), code quality (style guides like PEP 8/ESLint, DRY, SRP, clear naming), robustness (error handling, testing), maintainability (comments, documentation, modularity), and ethical considerations.
        *   **Crucial Rule Reminder:** All generated code *must* be reviewed and approved by a human developer before integration. Prioritize security and clarity.
    
    2.  **Define the Core Vibe & Project Brief:**
        *   Create a `PROJECT_BRIEF.md` file.
        *   Based on the human developer's input about the project's "vibe," target audience, and core purpose, outline:
            *   High-level project goal and concept.
            *   Key features (initially, maybe just for an MVP - Minimum Viable Product).
            *   Target user description.
            *   Desired look, feel, and user experience ("the vibe").
            *   Any major constraints or non-negotiables.
    
    3.  **Select Technology Stack:**
        *   Based on `PROJECT_BRIEF.md` and human developer guidance, propose and finalize the technology stack (e.g., frontend framework: React/Vue/Svelte, backend language/framework: Python/Node.js/Ruby on Rails, database: PostgreSQL/MongoDB, styling: Tailwind CSS/Bootstrap).
        *   Document the chosen stack in `PROJECT_BRIEF.md`.
    
    4.  **Setup Project Structure & Environment:**
        *   Create the basic directory structure for the project (e.g., `/src`, `/tests`, `/public`, `/docs`).
        *   Initialize project configuration files (e.g., `package.json`, `requirements.txt`, `.gitignore`, basic linter/formatter configs like `.eslintrc.js` or `pyproject.toml`).
        *   Set up virtual environments or container configurations (e.g., `venv`, `Dockerfile`).
    
    **Phase 2: Iterative Development Cycle (Repeat for Features/Modules)**
    
    5.  **Define Initial Tasks (MVP Focus):**
        *   Create a `TASKS.md` file.
        *   Based on `PROJECT_BRIEF.md`, break down the *first* core feature or the MVP into smaller, actionable coding tasks.
        *   Example Task Format: "- [ ] Implement user authentication endpoint (POST /api/login)".
    
    6.  **Implement Task (AI Generation & Human Review):**
        *   Select the highest priority task from `TASKS.md`.
        *   **AI Action:** Generate the necessary code (functions, classes, components, API endpoints, HTML structures, CSS rules) adhering strictly to `GLOBAL_RULES.md` and the project's chosen tech stack and style guides.
        *   **Human Action:** Thoroughly review the generated code for correctness, security vulnerabilities, adherence to rules, and overall quality. Request revisions from the AI as needed. *Do not proceed until the code is approved.*
    
    7.  **Write & Run Tests:**
        *   **AI Action:** Generate unit tests (and integration tests where appropriate) for the code implemented in the previous step. Ensure tests cover happy paths, edge cases, and error handling.
        *   **Human Action:** Review the generated tests. Run the tests and ensure they pass. Refine tests or code as necessary.
    
    8.  **Integrate & Verify:**
        *   **Human Action:** Integrate the approved and tested code into the main codebase.
        *   Manually test the feature/functionality in the context of the application to ensure it works as expected and doesn't break existing functionality.
    
    9.  **Refactor and Document:**
        *   **AI/Human Action:** Refactor the code if necessary for clarity, performance, or maintainability based on the integration experience.
        *   **AI Action:** Add or update necessary code comments, docstrings, and any relevant sections in user/developer documentation (e.g., update `README.md` with setup instructions or API usage).
        *   **Human Action:** Review comments and documentation.
    
    10. **Update Task List:**
        *   Mark the completed task in `TASKS.md`.
        *   Add any new tasks identified during the implementation or testing phase.
        *   Prioritize the next task(s).
        *   **(Loop back to Step 6 until MVP or current milestone is complete)**
    
    **Phase 3: Styling, Polish & Deployment Prep**
    
    11. **Apply Styling & UX ("Vibe"):**
        *   Implement the visual design and user experience elements described in `PROJECT_BRIEF.md`.
        *   Focus on responsiveness, accessibility, and consistency. Use AI to generate CSS/styling code, reviewed by humans.
    
    12. **End-to-End Testing & Security Audit:**
        *   **Human/AI Action:** Perform end-to-end testing simulating user flows.
        *   **Human Action:** Conduct a final security review, checking against OWASP Top 10 and the established `GLOBAL_RULES.md`. Use security scanning tools if available. Address any identified issues.
    
    13. **Final Documentation:**
        *   **AI/Human Action:** Ensure `README.md` is comprehensive (project overview, setup, usage, deployment). Generate or finalize any other required documentation (e.g., API docs).
    
    14. **Prepare for Deployment:**
        *   **AI/Human Action:** Configure environment variables for production (ensure NO secrets in code). Create build scripts (`npm run build`, etc.). Set up necessary infrastructure (hosting, database). Create deployment configurations (e.g., `Dockerfile` refinements, server configs).
    
    **Phase 4: Deployment & Beyond**
    
    15. **Deploy:**
        *   **Human Action:** Execute the deployment plan to make the application live.
    
    16. **Monitor & Iterate:**
        *   **Human Action:** Set up monitoring and logging for the live application.
        *   Gather user feedback.
        *   Plan for future iterations: Add new features (return to Phase 2, Step 5), fix bugs, and perform maintenance based on monitoring and feedback.
    
    ---
    
    **Note:** This workflow is iterative. Steps 6-10 form a core loop that will be repeated many times. Human judgment, context understanding, and final decision-making are essential throughout the entire process.
    

    To Use This:

    1. Save the Global Rules: Create a GLOBAL_RULES.md file containing the detailed rules discussed in the previous response (prioritize security, use linters, sanitize inputs, manage secrets, etc.).
    2. Save this Workflow: Save the markdown text above as VIBE_CODING_WORKFLOW.md.
    3. Feed to AI: When starting your project with the AI agent, instruct it to load and follow the steps outlined in VIBE_CODING_WORKFLOW.md, starting with Step 1 (which includes loading GLOBAL_RULES.md).
    4. Guide the Process: As the human developer, you will provide the specific inputs needed at each step (e.g., the core vibe, tech stack decisions, task prioritization, code reviews, deployment details).

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.