diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md new file mode 100644 index 0000000000..5875ce0cff --- /dev/null +++ b/.github/copilot-instructions.md @@ -0,0 +1,15 @@ +# GitHub Copilot Instructions + +You are an automated contributor to the ResInsight repository. + +## Source of Truth + +You MUST follow the canonical agent guidelines located in the `docs/agents/` directory: + +- **[docs/agents/core.md](../docs/agents/core.md)** - Core agent guidelines, architecture overview, PDM system, Python integration +- **[docs/agents/build.md](../docs/agents/build.md)** - Build system, prerequisites, test commands +- **[docs/agents/coding-style.md](../docs/agents/coding-style.md)** - Code formatting, style conventions +- **[docs/agents/repo-map.md](../docs/agents/repo-map.md)** - Repository structure and file locations +- **[docs/agents/workflow.md](../docs/agents/workflow.md)** - Safety guidelines and output expectations + +These documents contain the authoritative information about the project. Always consult them when working on code. diff --git a/CLAUDE.md b/CLAUDE.md index d05a4db11c..21f2f40e14 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -10,57 +10,8 @@ You MUST follow the canonical agent guidelines located in the `docs/agents/` dir - **[docs/agents/build.md](docs/agents/build.md)** - Build system, prerequisites, test commands - **[docs/agents/coding-style.md](docs/agents/coding-style.md)** - Code formatting, style conventions - **[docs/agents/repo-map.md](docs/agents/repo-map.md)** - Repository structure and file locations +- **[docs/agents/workflow.md](docs/agents/workflow.md)** - Safety guidelines and output expectations These documents contain the authoritative information about the project. Always consult them when working on code. -## Claude-Specific Rules - -### Change Philosophy -- Prefer minimal diffs - make the smallest possible changes to achieve the goal -- Do not reformat unrelated code -- Preserve existing code style and comments -- Only modify files directly related to your task - -### Safety Guidelines -- Never modify CI/CD configuration unless explicitly asked -- Always validate changes don't break existing behavior -- Always validate changes don't introduce security vulnerabilities -- If unsure about a change, stop and explain the uncertainty to the user - -### Testing -- Run existing linters and tests before making changes -- Run linters and tests after making changes -- Do not add new testing tools unless necessary -- Do not remove or modify unrelated tests - -## Output Expectations - -### Before Making Changes -- Explain your reasoning and approach -- List the specific files that will be modified -- Describe the expected impact of the changes - -### When Making Changes -- Make incremental, focused changes -- Test each change before proceeding -- Report progress frequently using the `report_progress` tool - -### After Making Changes -- Verify the changes work as expected -- Run relevant tests and linters -- Document any issues or limitations discovered - -## Working with Python - -When working with Python code: -- Always format code with `ruff format` -- Always check style with `ruff check --fix` -- Run these before committing changes - -## Commit Messages - -Follow these conventions: -- Start with issue number: `#12773 Python: Add API for creating valve templates` -- Use standard git commit message format -- Only use line breaks between paragraphs in the description -- Keep first line concise and descriptive \ No newline at end of file +Use `report_progress` to report progress frequently while working. \ No newline at end of file diff --git a/docs/agents/coding-style.md b/docs/agents/coding-style.md index b4a747b410..72a2594c91 100644 --- a/docs/agents/coding-style.md +++ b/docs/agents/coding-style.md @@ -46,7 +46,7 @@ python -m ruff check --fix test_polygons.py 1. **Minimal Changes**: Make the smallest possible changes to achieve the goal 2. **Preserve Formatting**: Do not reformat unrelated code -3. **Comments**: Match the style of existing comments in the file +3. **Comments**: Match the style of existing comments in the file, keep them concise and as short as possible while still being clear 4. **Libraries**: Use existing libraries whenever possible; only add new libraries or update versions if absolutely necessary ### Code Quality @@ -69,17 +69,27 @@ python -m ruff check --fix test_polygons.py Put function bodies in the `.cpp` file, not inline in the header. - Declare member functions in the header; define them in the matching `.cpp`. -- This applies even to one-line bodies (`return false;`, `return m_field;`, trivial forwarders). -- Exceptions: function templates that must stay in the header, and `constexpr` functions where the compiler requires the definition to be visible. +- Exceptions: function templates that must stay in the header, `constexpr` functions where the compiler requires the definition to be visible, and functions with an empty body (`{}`) or a short initializer list. ```cpp -// Bad – inline body in the header +// OK – short one-line body allowed inline class RimFoo { public: bool canAddSubCollection() const override { return false; } }; +// Bad – multi-statement body inline in the header +class RimFoo +{ +public: + bool canAddSubCollection() const override + { + if ( m_locked ) return false; + return m_children.empty(); + } +}; + // Good – declared in the header, defined in the .cpp // RimFoo.h class RimFoo @@ -91,8 +101,23 @@ public: // RimFoo.cpp bool RimFoo::canAddSubCollection() const { - return false; + if ( m_locked ) return false; + return m_children.empty(); } + +// OK – empty body / short initializer list allowed inline +class RimBar +{ +public: + void reset() {} + RimBar( int value ) + : m_value( value ) + { + } + +private: + int m_value = 0; +}; ``` Why: keeps headers light (faster builds, smaller include surface), keeps the implementation file as the single source of truth for behavior, and matches the existing style across `ApplicationLibCode`. diff --git a/docs/agents/workflow.md b/docs/agents/workflow.md new file mode 100644 index 0000000000..3ab8a62344 --- /dev/null +++ b/docs/agents/workflow.md @@ -0,0 +1,27 @@ +# Agent Workflow Guidelines + +This document describes how AI agents should operate when making changes to ResInsight. + +## Safety Guidelines + +- Never modify CI/CD configuration unless explicitly asked +- Always validate changes don't break existing behavior +- Always validate changes don't introduce security vulnerabilities +- If unsure about a change, stop and explain the uncertainty to the user + +## Output Expectations + +### Before Making Changes +- Explain your reasoning and approach +- List the specific files that will be modified +- Describe the expected impact of the changes + +### When Making Changes +- Make incremental, focused changes +- Test each change before proceeding +- Report progress frequently + +### After Making Changes +- Verify the changes work as expected +- Run relevant tests and linters +- Document any issues or limitations discovered