Skip to content

Add dotnet format pre-commit hook and CLAUDE.md symlink#753

Merged
berezovskyi merged 2 commits into
mainfrom
chore/dotnet-format-hook
May 17, 2026
Merged

Add dotnet format pre-commit hook and CLAUDE.md symlink#753
berezovskyi merged 2 commits into
mainfrom
chore/dotnet-format-hook

Conversation

@berezovskyi
Copy link
Copy Markdown
Member

@berezovskyi berezovskyi commented May 17, 2026

Summary

  • Symlink CLAUDE.mdAGENTS.md so Claude Code automatically loads the existing agent instructions (mirrors the existing .aider.md / .clinerules / .cursorrules pattern). Without this, Claude Code only sees the parent-directory CLAUDE.md, which has no formatting guidance — the in-repo AGENTS.md instruction to run dotnet format was effectively invisible.
  • Restructure the formatting guidance in AGENTS.md from a single buried line into a dedicated ## Formatting section. Spells out the exact command (dotnet format whitespace + dotnet format style --no-restore), explains why analyzers is excluded (slow + third-party rules treated as errors elsewhere), and calls out merge commits as a known drift source.
  • Add a local pre-commit hook that runs both subcommands with --verify-no-changes whenever .cs files are staged. Verify-only (no auto-fix) so the failure is loud and the developer runs the documented fix command themselves.

Test plan

  • pre-commit install then stage a deliberately mis-indented .cs file and git commit — hook should fail with the offending file path
  • Stage a clean .cs change — hook should pass
  • Stage a non-.cs change (e.g. README edit) — dotnet-format hook should be skipped (files filter)
  • cat CLAUDE.md resolves to AGENTS.md contents (symlink works on Linux + macOS)
  • Open a fresh Claude Code / aider / cursor session in the repo and confirm the new Formatting section is loaded into context

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Documentation

    • Expanded developer documentation with comprehensive code formatting guidelines and requirements.
  • Chores

    • Implemented automated code formatting validation to enforce consistency across the codebase during the commit process.

Review Change Stack

- Symlink CLAUDE.md -> AGENTS.md so Claude Code loads the existing
  agent instructions (mirrors the .aider.md/.clinerules/.cursorrules pattern)
- Replace the buried "Run dotnet format before commit" line in AGENTS.md
  with a dedicated Formatting section that spells out the exact command
  (whitespace + style only; analyzers is slow/noisy) and flags merge
  commits as a known style-drift source
- Add a local pre-commit hook that runs both subcommands with
  --verify-no-changes when .cs files are staged, so drift fails the
  commit instead of being noticed in CI or review

Run 'pre-commit install' once per clone to activate the hook.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 17, 2026

Warning

Rate limit exceeded

@berezovskyi has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 41 minutes and 55 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: fc5446c0-3fb7-4ad9-ab9e-41b3399f4049

📥 Commits

Reviewing files that changed from the base of the PR and between 9c22f0b and b8b1339.

⛔ Files ignored due to path filters (2)
  • docs/images/logo.svg is excluded by !**/*.svg
  • misc/_static/logo.svg is excluded by !**/*.svg
📒 Files selected for processing (47)
  • .coderabbit.yaml
  • .pre-commit-config.yaml
  • .vscode/settings.json
  • .vscode/tasks.json
  • OSLC4Net_SDK/.config/dotnet-tools.json
  • OSLC4Net_SDK/.dockerignore
  • OSLC4Net_SDK/Examples/OSLC4Net.Client.Jazz/Oslc/Jazz/JazzConstants.cs
  • OSLC4Net_SDK/Examples/OSLC4Net.Client.Jazz/Oslc/Jazz/JazzFormAuthClient.cs
  • OSLC4Net_SDK/Examples/OSLC4Net.Client.Jazz/Oslc/Jazz/JazzRootServicesConstants.cs
  • OSLC4Net_SDK/Examples/OSLC4Net.Client.Samples/ERMSample.cs
  • OSLC4Net_SDK/Examples/OSLC4Net.Client.Samples/ETMSample.cs
  • OSLC4Net_SDK/Examples/OSLC4Net.Client.Samples/EWMSample.cs
  • OSLC4Net_SDK/Examples/OSLC4Net.Client.Samples/Program.cs
  • OSLC4Net_SDK/Examples/OSLC4Net.Client.Samples/Properties/AssemblyInfo.cs
  • OSLC4Net_SDK/Examples/OSLC4Net.Client.Samples/SampleBase.cs
  • OSLC4Net_SDK/Examples/OSLC4NetExamples.Server.NetCoreApi/Dockerfile
  • OSLC4Net_SDK/Examples/OSLC4NetExamples.Server.NetCoreApi/Models/RootServicesDto.cs
  • OSLC4Net_SDK/Examples/scripts/README.md
  • OSLC4Net_SDK/OSLC4Net.ChangeManagement/OSLC4Net.ChangeManagementCommon.csproj.DotSettings
  • OSLC4Net_SDK/OSLC4Net.Client/Oslc/OslcClient.cs
  • OSLC4Net_SDK/OSLC4Net.Core.Query/Grammars/OslcOrderBy.g
  • OSLC4Net_SDK/OSLC4Net.Core.Query/Grammars/OslcPrefix.g
  • OSLC4Net_SDK/OSLC4Net.Core.Query/Grammars/OslcSearchTerms.g
  • OSLC4Net_SDK/OSLC4Net.Core.Query/Grammars/OslcSelect.g
  • OSLC4Net_SDK/OSLC4Net.Core.Query/Grammars/OslcWhere.g
  • OSLC4Net_SDK/OSLC4Net.Core.Query/Impl/GeneratingParsers.txt
  • OSLC4Net_SDK/OSLC4Net.Core.Query/Impl/OslcOrderByLexer.cs
  • OSLC4Net_SDK/OSLC4Net.Core.Query/Impl/OslcOrderByParser.cs
  • OSLC4Net_SDK/OSLC4Net.Core.Query/Impl/OslcPrefixLexer.cs
  • OSLC4Net_SDK/OSLC4Net.Core.Query/Impl/OslcPrefixParser.cs
  • OSLC4Net_SDK/OSLC4Net.Core.Query/Impl/OslcSearchTermsLexer.cs
  • OSLC4Net_SDK/OSLC4Net.Core.Query/Impl/OslcSearchTermsParser.cs
  • OSLC4Net_SDK/OSLC4Net.Core.Query/Impl/OslcSelectLexer.cs
  • OSLC4Net_SDK/OSLC4Net.Core.Query/Impl/OslcSelectParser.cs
  • OSLC4Net_SDK/OSLC4Net.Core.Query/Impl/OslcWhereLexer.cs
  • OSLC4Net_SDK/OSLC4Net.Core.Query/Impl/OslcWhereParser.cs
  • OSLC4Net_SDK/OSLC4Net.Core/Attribute/OslcAllowedValues.cs
  • OSLC4Net_SDK/OSLC4Net.Core/Model/IResource.cs
  • OSLC4Net_SDK/Tests/OSLC4Net.Core.DotNetRdfProviderTests/AllowedValuesSerializationTests.cs
  • OSLC4Net_SDK/Tests/OSLC4Net.Core.DotNetRdfProviderTests/Properties/AssemblyInfo.cs
  • OSLC4Net_SDK/Tests/OSLC4NetExamples.Server.Tests/Models/RootServicesDtoTests.cs
  • OSLC4Net_SDK/Tests/OSLC4NetExamples.Server.Tests/TestData/rootservices.rdf
  • OSLC4Net_SDK/Tests/OSLC4NetExamples.Server.Tests/TestData/rootservices2.rdf
  • OSLC4Net_SDK/global.json
  • misc/instructions/gov-uk-technical-content.md
  • misc/instructions/iso-house-guide.md
  • scripts/Generate-LlmTxt.ps1

Walkthrough

A local pre-commit hook is added to enforce C# code formatting via dotnet format verification on .cs files. Developer documentation is updated with detailed formatting requirements, command usage, and guidance on handling merge conflicts, with a reference file added.

Changes

Code formatting enforcement via pre-commit hook

Layer / File(s) Summary
Pre-commit hook and formatting documentation
.pre-commit-config.yaml, AGENTS.md, CLAUDE.md
A local dotnet-format hook is added to .pre-commit-config.yaml to verify whitespace and style in .cs files within OSLC4Net_SDK. AGENTS.md replaces a brief formatting reminder with a detailed "Formatting (required before every commit)" section that documents the exact commands, --no-restore usage, post-merge-conflict guidance, and references the pre-commit hook enforcement. CLAUDE.md is updated to reference AGENTS.md.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 A bunny's ode to the format way:
Lines aligned with style so true,
Pre-commit hooks enforce what's due,
No whitespace chaos shall pass through,
Clean C# code for me and you! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately captures both main changes: adding the dotnet format pre-commit hook and creating the CLAUDE.md symlink. It is specific, concise, and clearly summarizes the primary objectives.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/dotnet-format-hook

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@AGENTS.md`:
- Around line 102-106: The two conflicting instructions (the dotnet format
command that uses ./OSLC4Net_SDK and the earlier note that says you must be
inside OSLC4Net_SDK) should be reconciled: pick one consistent workflow and
update the text accordingly—either change the command to run without the
relative path when instructing "run from repo root" or change the guidance to
"cd into OSLC4Net_SDK" and remove the ./OSLC4Net_SDK prefix; update the examples
(the dotnet format whitespace ... and dotnet format style ... --no-restore) and
the prior sentence referencing being inside OSLC4Net_SDK so both reflect the
same location guidance.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: bb5d1db6-6ff7-4fc1-9e1a-948ed313e1f5

📥 Commits

Reviewing files that changed from the base of the PR and between 6617465 and 9c22f0b.

📒 Files selected for processing (3)
  • .pre-commit-config.yaml
  • AGENTS.md
  • CLAUDE.md

Comment thread AGENTS.md
Comment on lines +102 to +106
Run from the repo root:

```bash
dotnet format whitespace ./OSLC4Net_SDK && dotnet format style ./OSLC4Net_SDK --no-restore
```
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Conflicting command location guidance in this file

Line 102 says to run from repo root, but Line 57 says you must be inside OSLC4Net_SDK before running dotnet commands. Please make these instructions consistent in one direction to avoid developer confusion.

As per coding guidelines AGENTS.md: “Document agent implementations and capabilities in AGENTS.md file”.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@AGENTS.md` around lines 102 - 106, The two conflicting instructions (the
dotnet format command that uses ./OSLC4Net_SDK and the earlier note that says
you must be inside OSLC4Net_SDK) should be reconciled: pick one consistent
workflow and update the text accordingly—either change the command to run
without the relative path when instructing "run from repo root" or change the
guidance to "cd into OSLC4Net_SDK" and remove the ./OSLC4Net_SDK prefix; update
the examples (the dotnet format whitespace ... and dotnet format style ...
--no-restore) and the prior sentence referencing being inside OSLC4Net_SDK so
both reflect the same location guidance.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 17, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 52.20%. Comparing base (6617465) to head (b8b1339).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #753   +/-   ##
=======================================
  Coverage   52.20%   52.20%           
=======================================
  Files         174      174           
  Lines       10254    10254           
  Branches     1021     1021           
=======================================
  Hits         5353     5353           
  Misses       4644     4644           
  Partials      257      257           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Signed-off-by: Andrew Berezovskyi <andriib@kth.se>
@berezovskyi berezovskyi enabled auto-merge May 17, 2026 09:28
@berezovskyi berezovskyi added this pull request to the merge queue May 17, 2026
Merged via the queue into main with commit ce774de May 17, 2026
12 checks passed
@berezovskyi berezovskyi deleted the chore/dotnet-format-hook branch May 17, 2026 09:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant