Agentic.Analyzers 0.2.5

dotnet add package Agentic.Analyzers --version 0.2.5
                    
NuGet\Install-Package Agentic.Analyzers -Version 0.2.5
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Agentic.Analyzers" Version="0.2.5">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Agentic.Analyzers" Version="0.2.5" />
                    
Directory.Packages.props
<PackageReference Include="Agentic.Analyzers">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Agentic.Analyzers --version 0.2.5
                    
#r "nuget: Agentic.Analyzers, 0.2.5"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Agentic.Analyzers@0.2.5
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Agentic.Analyzers&version=0.2.5
                    
Install as a Cake Addin
#tool nuget:?package=Agentic.Analyzers&version=0.2.5
                    
Install as a Cake Tool

Agentic.Analyzers

A Roslyn analyzer for agentic-AI-authored C#. Distributed as a NuGet package and consumed exactly like StyleCop — add a PackageReference, pick a tier, done.

It enforces three nested rule families: AI (discipline / anti-"AI slop"), PERFAI (zero-GC performance), and AOTAI (NativeAOT strictness).

A separate, Clang-based C++ analyzer (cpp-ai / cpp-perf) ships in the same repository but is not part of this NuGet package — see C++ analyzer below.

Install

Install the analyzer package from NuGet in each project that should enforce the rules. Keep PrivateAssets="all" so analyzer-only assets do not flow transitively to downstream consumers.

Set AiRuleTier in the same project file to choose the rule set for that project.

<ItemGroup>
  <PackageReference Include="Agentic.Analyzers" Version="0.2.4" PrivateAssets="all" />
</ItemGroup>
<PropertyGroup>
  <AiRuleTier>Aot</AiRuleTier>
</PropertyGroup>

Use the latest version published on NuGet. Tune individual rules through .editorconfig severities, e.g. dotnet_diagnostic.PERFAI0001.severity = error.

AiRuleTier values

Rules are grouped into three nested tiers, selected per project via the AiRuleTier MSBuild property:

Tier (AiRuleTier) Prefix Enforces
Base AI#### Discipline — anti-"AI slop": no comments, no swallowed exceptions, no dead structure, no hidden flags, no silent fallbacks
Perf PERFAI#### Base + zero-GC — no heap allocation, no LINQ, no boxing, spans/in/ValueTask in the API surface
Aot AOTAI#### Perf + NativeAOT strictness — no reflection, no dynamic, no runtime codegen, no reflection-based serialization

None disables all rules. Nesting: Base ⊂ Perf ⊂ Aot. All rules are category-scoped (Agentic.Discipline / Agentic.Perf / Agentic.Aot), severity Warning by default.

Rules

Base tier — AI#### (Agentic Discipline)

ID Rule
AI0001 Comments are not permitted
AI0002 Empty catch block is not permitted
AI0003 Catching System.Exception or a general catch is not permitted
AI0004 Rethrowing with throw ex is not permitted
AI0005 Redundant else after a terminating if branch is not permitted
AI0006 Comparison against a boolean literal is not permitted
AI0007 Redundant this. qualification is not permitted
AI0008 #region directives are not permitted
AI0009 Console output is not permitted
AI0010 async void is not permitted
AI0011 Synchronous blocking on asynchronous code is not permitted
AI0012 Throwing NotImplementedException is not permitted
AI0013 Public mutable field is not permitted
AI0014 Boolean parameter on a public or internal method is not permitted
AI0015 Method with more than five parameters is not permitted
AI0016 Nested conditional expression is not permitted
AI0017 Single-use local that is immediately returned is not permitted
AI0018 Redundant ToString in string interpolation is not permitted
AI0019 Empty statement or placeholder method body is not permitted
AI0020 Discarded Task is not permitted
AI0021 Magic number is not permitted
AI0022 Unsandboxed process or shell execution is not permitted
AI0023 Hidden ai mode flag is not permitted
AI0024 Discarded IDisposable is not permitted
AI0025 Throwing a generic base exception type is not permitted
AI0026 Silent default value is not permitted
AI0027 Silent fallback value is not permitted

Perf tier — PERFAI#### (Zero-GC Performance)

Includes all Base rules, plus:

ID Rule
PERFAI0001 Array allocation is not permitted
PERFAI0002 LINQ is not permitted
PERFAI0003 Boxing allocation is not permitted
PERFAI0004 Closure capture is not permitted
PERFAI0005 params array is not permitted
PERFAI0006 String composition inside a loop is not permitted
PERFAI0007 Eager LINQ materialization is not permitted
PERFAI0008 foreach over an interface is not permitted
PERFAI0009 Dictionary double lookup is not permitted
PERFAI0010 Explicit StringComparison is required
PERFAI0011 Public class should be sealed
PERFAI0012 Struct should be readonly
PERFAI0013 Array parameter should be a Span
PERFAI0014 Task return should be a ValueTask
PERFAI0015 readonly struct parameter should be passed by in

Aot tier — AOTAI#### (NativeAOT Strictness)

Includes all Base + Perf rules, plus:

ID Rule
AOTAI0001 Reflection is not permitted
AOTAI0002 Activator.CreateInstance is not permitted
AOTAI0003 Runtime member reflection is not permitted
AOTAI0004 System.Reflection.Emit is not permitted
AOTAI0005 Compiling LINQ expression trees is not permitted
AOTAI0006 The dynamic type is not permitted
AOTAI0007 Runtime generic construction is not permitted
AOTAI0008 Runtime assembly loading is not permitted
AOTAI0009 BinaryFormatter is not permitted
AOTAI0010 Reflection-based serializers are not permitted
AOTAI0011 Reflection-based JsonSerializer usage is not permitted
AOTAI0012 Calling a RequiresUnreferencedCode / RequiresDynamicCode member is not permitted
AOTAI0013 RuntimeHelpers.GetUninitializedObject is not permitted
AOTAI0014 TypeDescriptor is not permitted
AOTAI0015 Convert.ChangeType is not permitted

C++ analyzer (separate, Clang-based)

The repository also ships an agentic C++ analyzer. It is a separate project, not distributed via this NuGet package — it is Clang-based (LibTooling / clang-tidy, requires LLVM/Clang ≥ 18) and consumed via CMake + clang-tidy config, not by a PackageReference. It has two append-model tiers: cpp-ai (discipline + correctness + safety) and cpp-perf (= cpp-ai ∪ performance / zero-overhead).

Two enforcement surfaces:

  1. Built-in clang-tidy profilescpp/profiles/cpp-ai.clang-tidy and cpp/profiles/cpp-perf.clang-tidy (curated bugprone-*, cert-*, misc-*, readability-*, modernize-*, cppcoreguidelines-*, clang-analyzer-*, performance-*, readability-magic-numbers; all WarningsAsErrors).
  2. Custom AGENTIC-#### checks — Clang AST-matcher callbacks in cpp/tools/agentic-cpp-perf for semantics the built-ins cannot express.

Custom AGENTIC-PERF-#### (hot-path / zero-overhead)

ID Rule
AGENTIC-PERF-0001 std::shared_ptr passed by value (atomic refcount churn)
AGENTIC-PERF-0002 Heap allocation (new / make_unique / make_shared) inside a loop body
AGENTIC-PERF-0004 std::function value parameter on a hot path
AGENTIC-PERF-0005 Large record (> 2 machine words) passed by value
AGENTIC-PERF-0007 Move ctor / move assignment not noexcept
AGENTIC-PERF-0010 Raw owning new / delete (RAII violation)

Deferred as not reliably single-TU decidable: AGENTIC-PERF-0003 (closed-set virtual dispatch → variant), -0006 (unique ownership → unique_ptr), -0008 (const-foldable → constexpr). AGENTIC-PERF-0009 (range-for copy) is covered by the built-in performance-for-range-copy.

Custom AGENTIC-AI-#### (discipline / safety)

ID Rule
AGENTIC-AI-0001 Uninsulated shell-out via system / std::system
AGENTIC-AI-0002 std::cout pollutes the machine protocol stream (use std::cerr for tracing)
AGENTIC-AI-0003 Hidden boolean ai flag / parameter
AGENTIC-AI-0004 Generic / catch-all exceptions (throwing a std:: base; non-rethrowing catch (...))
AGENTIC-AI-0005 Silent default fallback (empty/break;-only default:; value-init returned from a catch)
AGENTIC-AI-0006 Silent fallback value (value_or(<literal>), has_value() ? … : <literal>)

See design/rules-cpp.md for the full C++ triage (including the architectural, doc-only anti-patterns enforced elsewhere in the cogOS stack).

License

MIT.

There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.2.5 138 6/22/2026
0.2.3 111 6/22/2026

Minor release for the next analyzer rule condition and NuGet publishing setup.