Skip to main content
skill CX Codex

item-management — Claude Code skill: what it does, how to install

Guides AI agents through MSBuild ItemGroup semantics and item expressions. It covers Include, Remove, Update operations, item batching, and metadata transforms.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add dotnet/skills --skill item-management -a claude-code
Open on GitHub

What item-management does

This skill brings canonical MSBuild item patterns derived from Microsoft.Common.CurrentVersion.targets into your coding agent. It clarifies core semantics for Include, Remove, and Update. The Update operation only modifies existing items without adding new ones. Similarly, Exclude is valid on Include calls, not on Update or Remove.

The skill covers target and task batching using %(Metadata) along with item transforms like @(Item->'expression'). Mixing metadata from different item groups in a single expression causes an O(N×M) cross-product execution. That blows up build times immediately. For pure property issues or non-MSBuild build tools, this skill is out of scope. Generated files must target $(IntermediateOutputPath) and register under @(FileWrites) so dotnet clean works as intended.

What it helps with

  • correct item metadata updates in MSBuild using Update
  • subtract items from compilation using Remove or Exclude
  • prevent O(N×M) cross-product execution during target and task batching
  • transform item paths for destination outputs via @(Item->'expression')
  • track generated build artifacts in @(FileWrites) for clean builds

Example prompts for the agent

  • Review this MSBuild ItemGroup: why is Update not adding missing files to Compile?
  • Help me set up task batching on %(Culture) without creating a cross-product.
  • How do I subtract assemblies from Reference and clear temporary items properly?

How to install item-management

1Skills CLI (Vercel)

npx skills add dotnet/skills --skill item-management -a claude-code

2Manually: put the files in place

~/.claude/skills/item-management/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/item-management/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about item-management

How to install item-management in Claude Code?

Run npx skills add dotnet/skills --skill item-management -a claude-code in your terminal.

What does the item-management skill do?

It guides coding agents on correct MSBuild ItemGroup logic. It provides rules for Include, Remove, Update, metadata batching, and item transforms.

When should this skill be excluded?

It excludes property-only issues, general build incrementality without item questions, and build systems other than MSBuild.

Source text

SKILL.md · MIT
---
name: item-management
description: "Own concrete MSBuild ItemGroup and item-expression questions. USE FOR: Include, Remove, Update, item identity and metadata, transforms, filtering, batching, duplicate or overlapping items, and reviews that verify whether those operations are correct. Generated items stay in scope when the central defect is item identity, metadata, batching, duplicate declarations, or glob/Remove/Update semantics. For a generated artifact missing from compilation or output, wrong target timing/path, or FileWrites clean tracking without a broader item-semantics defect, use including-generated-files. The item operation may be broken, suspected, or already correct. Exclude property-only issues, general incrementality with no item question, broad reviews with no concrete item concern, and non-MSBuild systems."
license: MIT
---

# MSBuild Item Management Patterns

Canonical patterns for working with item groups, from `Microsoft.Common.CurrentVersion.targets`.

## Include / Remove / Update — Three Operations

| Operation | Purpose | When to use |
|---|---|---|
| `Include` | Add new items to the group | Creating items with identity + metadata |
| `Remove` | Remove items matching a pattern | Excluding files or clearing a group |
| `Update` | Modify metadata on existing items | Adding/changing metadata without re-adding |

### Include — Add Items

```xml
<ItemGroup>
  <Compile Include="Generated\*.cs">
    <AutoGen>true</AutoGen>
  </Compile>
</ItemGroup>
```

### Remove — Subtract Items

```xml
<ItemGroup>
  <!-- Remove specific items -->
  <Reference Remove="$(AdditionalExplicitAssemblyReferences)" />

  <!-- Set subtraction: prior minus current -->
  <_CleanOrphanFileWrites Include="@(_CleanPriorFileWrites)"
      Exclude="@(_CleanCurrentFileWrites)" />

  <!-- Clear an entire group -->
  <_Temporary Remove="@(_Temporary)" />
</ItemGroup>
```

### Update — Modify Existing Items

```xml
<ItemGroup>
  <EmbeddedResource Update="@(EmbeddedResource)"
      Condition="'%(NuGetPackageId)' == 'Microsoft.CodeAnalysis.Collections'">
    <GenerateSource>true</GenerateSource>
    <ClassName>Microsoft.CodeAnalysis.Collections.SR</ClassName>
  </EmbeddedResource>
</ItemGroup>
```

`Update` does not add items — it only modifies items already in the group.

## Item Batching — %(Metadata)

When `%(Metadata)` appears in target attributes or task parameters, MSBuild **batches** execution per unique metadata value.

### Target-level batching (Outputs)

```xml
<Target Name="GenerateSatelliteAssemblies"
    Inputs="$(MSBuildAllProjects);@(_SatelliteAssemblyResourceInputs)"
    Outputs="$(IntermediateOutputPath)%(Culture)\$(TargetName).resources.dll">
  <!-- Runs once per unique Culture value -->
</Target>
```

### Task-level batching

```xml
<Copy SourceFiles="@(_SourceItems)"
    DestinationFiles="@(_SourceItems->'$(OutDir)%(TargetPath)')">
</Copy>
```

### Per-item filtering with Condition

```xml
<ItemGroup>
  <_ResxOutput Include="@(EmbeddedResource->'%(OutputResource)')"
      Condition="'%(EmbeddedResource.WithCulture)' == 'false'" />
</ItemGroup>
```

### Batching rules

- `%(Metadata)` in `Condition` or `Outputs` → target batches per unique value.
- `%(Metadata)` in task parameters → task batches per unique value.
- **Do not mix `%()` from different item groups** in the same expression — this causes a cross-product (see Common Pitfalls).

## Item Transforms — @(Item->'expression')

Transforms create new item lists by applying an expression to each item:

```xml
<!-- Transform file paths to destinations -->
<Copy SourceFiles="@(IntermediateAssembly)"
    DestinationFiles="@(IntermediateAssembly->'$(OutDir)%(Filename)%(Extension)')"/>

<!-- Transform with separator for display -->
<Message Text="Files: @(Compile->'%(Filename)', ', ')" />
```

## Exclude Pattern — Set Subtraction on Include

```xml
<ItemGroup>
  <Compile Include="**\*.cs" Exclude="Generated\**;Tests\**" />
</ItemGroup>
```

`Exclude` only works on `Include` — it cannot be used with `Update` or `Remove`.

## Conditional Item Inclusion

```xml
<!-- Condition on ItemGroup — all or nothing -->
<ItemGroup Condition="'$(NetCoreBuild)' == 'true'">
  <PackageReference Include="System.IO.Pipelines" />
</ItemGroup>

<!-- Condition on individual items -->
<ItemGroup>
  <PackageReference Include="System.IO.Pipelines"
      Condition="'$(NetCoreBuild)' == 'true'" />
</ItemGroup>
```

## PrivateAssets on Tool/Analyzer Packages

```xml
<ItemGroup>
  <PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" PrivateAssets="all" />
  <PackageReference Include="StyleCop.Analyzers" PrivateAssets="all" />
</ItemGroup>
```

## Common Pitfalls

### Cross-product batching

Referencing `%(Metadata)` from two different item groups creates O(N×M) executions:

```xml
<!-- BAD: Cross-product of @(Source) × @(Config) -->
<Exec Command="process %(Source.Identity) with %(Config.Identity)" />

<!-- GOOD: Reference one group via batching, the other via property -->
<Exec Command="process %(Source.Identity) with $(ConfigFile)" />
```

### Generated files in source tree

Write to `$(IntermediateOutputPath)` (obj/), not the source directory. Source-tree generation pollutes version control and can cause duplicate compilation via globs.

### Missing FileWrites

Every file created during a target must be added to `@(FileWrites)` for `dotnet clean` support.

© dotnet · MIT · dotnet/skills

Similar skills

Everything for Backend and APIs →

From the same set101

maui-collectionview A reference skill for CollectionView in .NET MAUI: item templates, grids, grouping, incremental loading and swipe actions. Useful when the agent writes list XAML. CX Codex +1 3,200installs use-js-interop Sets up and audits JavaScript interop in Blazor components. It guides .NET-to-JS calls, lifecycle handling, and call batching across the circuit. CX Codex +1 3,000installs convert-blazor-server-to-webapp Guides a pre-.NET 8 Blazor Server app to the Blazor Web App model. Use it when replacing the old host setup while retaining interactive server rendering. CX Codex +1 3,000installs extension-points This skill maps how MSBuild discovers hooks and imports: CustomBefore/CustomAfter, wildcard directories, NuGet auto-imports. Useful when assets go missing or get replaced. CX Codex +1 3,000installs plan-ui-change Splits a complex Blazor page into focused components before the agent writes any code. Useful once a screen has three or more visual sections. CX Codex +1 3,000installs collect-user-input A skill that walks the agent through Blazor forms, input components and validation. Useful when you add a form, a search box or file upload to a page. CX Codex +1 3,000installs coordinate-components Helps AI agents share state across Blazor components without parent-child parameter chains. Covers cascading parameters, scoped services, and render mode boundaries. CX Codex +1 3,000installs create-blazor-project The skill walks the agent through picking a Blazor render mode and runs dotnet new blazor with the right flags. CX Codex +1 3,000installs

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor