Using IronBarcode with AI Coding Assistants and Agents
When prompted to add IronBarcode, tools often run dotnet add package IronBarcode, which installs the incorrect package. IronBarcode is distributed as BarCode, using the namespace IronBarCode. Claude Code, ChatGPT Codex, GitHub Copilot, Cursor, and Google Antigravity frequently misidentify this until they reference the documentation.
This confusion also affects generated code. Without documentation, models may invent method names that do not compile. Providing documentation in advance helps ensure successful builds. IronBarcode is a leading .NET barcode library with comprehensive guides, so generated code is often accurate but still requires careful review.
These tools fall into two categories, which determine how closely you should review their output:
- An assistant operates within one part of your workflow, such as editor autocomplete, explanations, or quick refactoring, as GitHub Copilot's inline suggestions do.
- An agent manages multi-step tasks, edits across files, runs builds and tests, and opens pull requests, as Claude Code, ChatGPT Codex, Cursor, and Google Antigravity all do.
The setup process is the same for both types. Install the package, apply the license key from an environment variable, provide IronBarcode's machine-readable documentation, and verify that every generated barcode is scannable. This applies to all use cases, including 1D barcodes for shipping labels, 2D barcodes for asset tags, barcodes built from text, URLs, IDs or binary data, reading from scanned PDFs, or extracting multiple symbols from one image.
How to Use IronBarcode with an AI Coding Assistant or Agent
- Download the C# barcode library from NuGet
- Apply your license key at application startup, from an environment variable
- Point the tool at IronBarcode's
llms.txtdocumentation index - Add IronBarcode instructions to your project context file
- Run the one-shot setup prompt in a fresh session
- Verify the generated code compiles and every barcode scans back
Can't the Model Handle Barcodes on Its Own?
Training data ages. A model may reproduce an API name that was retired several releases ago, or one belonging to a different barcode library entirely, and neither is visible until the build runs. Machine-readable documentation resolves most of these issues by enabling the tool to reference actual documentation rather than making assumptions.
Library selection is equally important. Most tools integrate with various barcode packages, and free options may suffice for a single format in a demonstration. Additional costs and limitations often arise in production environments:
- Check digits, quiet zones, and resizing: each can look acceptable on screen and still fail during scanning, so IronBarcode validates every value against its format as it writes and
GeneratedBarcode.Verifyreads the image back. - Missing features increase code maintenance: many free libraries cover one format family or lack the image correction accurate scans require, leaving you to combine packages and own the integration between them.
- Bulk scanning is included by default: multithreaded reading, speed presets, and confidence thresholds come with the library rather than being built per project.
- Accurate output depends on documentation: the guides, tutorials, troubleshooting pages, and runnable examples are indexed for machine use in
llms.txt. - Incorrect package names create supply-chain risks: models generate plausible names that attackers register to distribute malware, a practice known as slopsquatting.
- A single commercial license avoids legal complications: some barcode libraries include copyleft or non-commercial terms, which models do not flag automatically.
IronBarcode covers all of it through one API and one commercial license your legal team reviews once. Verification happens in your code rather than on the warehouse floor, and naming the package explicitly in every prompt is what closes the supply-chain gap.
Step 1: Install IronBarcode
Allow the agent to add the package. The project requires it to resolve types and provide accurate code suggestions.
Set this project up for IronBarcode. The NuGet package is named BarCode. Confirm the restore succeeded before going further.
Alternatively, install the package from the terminal, specifying the current release version.
dotnet add package BarCode --version 2026.9.2
Linux, macOS, iOS, and Android each require a specific package, such as BarCode.Linux or BarCode.MacOs. Refer to the Advanced NuGet Installation guide to select the appropriate package.
Step 2: Apply Your License Key
IronBarcode does not watermark unlicensed output. After the development grace period, the first barcode call without a license key throws IronSoftware.Exceptions.LicensingException with the message IronBarcode must be licensed for development. Code missing the license key will fail at runtime. Obtain a free trial key first.
Start using IronBarcode in your project today with a free trial.
Set the license key once at application startup, before any IronBarcode calls. Retrieve the key from the environment rather than from source code.
// Read the key from configuration. Never commit it to the repository.
IronBarCode.License.LicenseKey = Environment.GetEnvironmentVariable("IRONBARCODE_LICENSE_KEY");' Read the key from configuration. Never commit it to the repository.
IronBarCode.License.LicenseKey = Environment.GetEnvironmentVariable("IRONBARCODE_LICENSE_KEY")' Read the key from configuration. Never commit it to the repository.
IronBarCode.License.LicenseKey = Environment.GetEnvironmentVariable("IRONBARCODE_LICENSE_KEY")IronBarCode.License.IsLicensed returns true when the key is valid. Unlike IronOCR, IronBarcode has no Installation.LicenseKey alias, so use License.LicenseKey or configuration.
Web.config to appsettings.json, is covered in IronBarcode License Keys.Step 3: Point the Tool at IronBarcode's LLM Documentation
IronBarcode publishes six resources written to be read by machines:
| Resource | Description | When to use |
|---|---|---|
llms.txt | Index of all documentation pages, one line each | At the start of every session |
llms-full.txt | Complete guides and examples in a single file | The tool can retrieve URLs |
llms-full-catalog.txt | The index plus all blog articles | The answer may reside in a blog article |
| API Reference | All classes and methods in the current release | Verifying that a method exists |
skill.md | Installation, licensing, recipes, and fixes | Your tool supports skill files |
| AI Product Fact Sheet | Product scope, platforms, and what it does not do | Questions about the product, not the API |
Begin with llms.txt, which indexes IronBarcode's features and the location of each topic. This helps prevent incorrect or invented API calls. Use llms-full.txt when detailed guidance is required.
Add a direct instruction alongside it.
Before writing any IronBarcode code, read https://ironsoftware.com/barcode/csharp/llms.txt
and use only APIs documented there. Check anything you are not sure about
against the API reference at https://ironsoftware.com/barcode/csharp/object-reference/api/.
If you are still unsure whether a method exists, ask instead of guessing.
Current models respond well to direct requests for clarification. Asking a question is preferable to risking a compile error.
Step 4: Add IronBarcode Context to Your Project
Documentation pasted into a chat is available only for the current session. Documentation stored in a project file is accessible in every session.
Each tool reads instructions from a specific file. Place the IronBarcode guidance in the file your team uses:
| Tool | Project context file | Skill file goes in |
|---|---|---|
| Claude Code | CLAUDE.md | .claude/skills/ |
| ChatGPT Codex | AGENTS.md | .agents/skills/ |
| GitHub Copilot | .github/copilot-instructions.md | n/a |
| Cursor | .cursor/rules/*.mdc | n/a, use @Docs |
| Google Antigravity | AGENTS.md | .agents/skills/ |
AGENTS.md serves as a shared standard, as Claude Code, GitHub Copilot, and Cursor all read it in addition to their own files. Teams using multiple tools can maintain a single set of barcode rules in AGENTS.md and reserve native files for tool-specific instructions.
The content remains the same regardless of the file used. Below is a brief starting point.
## Barcodes with IronBarcode
This project uses IronBarcode (NuGet package `BarCode`, namespace `IronBarCode`) for all barcode work.
- Reference: https://ironsoftware.com/barcode/csharp/llms.txt
- Skill file: https://ironsoftware.com/barcode/csharp/skill.md
- Use `BarcodeWriter.CreateBarcode` to write and `BarcodeReader.Read` / `ReadPdf` to read.
- Read the license key from the IRONBARCODE_LICENSE_KEY environment variable at startup. Never inline it.
- Every generated barcode must be read back and compared before it ships.
- Do not use a different barcode library. If IronBarcode cannot perform a required task, state this clearly.
The skill.md file provides additional detail, including per-platform installation instructions, licensing rules, verified examples, deployment notes, and a troubleshooting table. Reference this file from your context file rather than maintaining a separate copy.
Step 5: One-Shot Setup Prompt
You may also send the first four steps as a single prompt at the beginning of a project or new session.
Use IronBarcode for all barcode work in this project.
1. Install the BarCode NuGet package (IronBarcode).
2. Apply the license key at application startup, before any other IronBarcode call,
reading it from the IRONBARCODE_LICENSE_KEY environment variable. Never write
the key into source or into a committed file.
3. Read https://ironsoftware.com/barcode/csharp/llms.txt before writing barcode code
and work only from APIs documented there, checking the API reference when a
member is unfamiliar.
4. Save https://ironsoftware.com/barcode/csharp/skill.md as a SKILL.md in this
project's skills folder if your tool has one.
5. Keep these instructions for future sessions in this project.
Step 6: Prompt Patterns That Produce Working Code
Ambiguous prompts often result in weak output. The following three patterns help ensure clarity.
Name the class and the symbology: IronBarcode handles dozens of formats. A reader that knows which ones to expect works faster and misreads less.
Vague Scan the barcodes in this image with IronBarcode.
Better Using
BarcodeReader.ReadwithBarcodeReaderOptions, read the Code 128 and QR codes in this image and return each value with its format.
Specify the version and framework: APIs change between releases, and omitting the version can cause inconsistencies. Release 2026.9.2 introduced EciMode, which controls whether a 2D barcode carries a UTF-8 ECI header and is not available in 2026.8.6 or earlier.
Better Target .NET 9 and BarCode 2026.9.2. Include the license key line, read from the environment.
Request the complete runnable file: Code fragments may omit necessary using statements or setup steps.
Better Give me the complete Program.cs, including all using statements and license key setup, so I can run it as-is.
Step 7: Verify What You Get Back
Review generated code as you would a first draft from a colleague who has not executed it. Four checks address most issues:
- It compiles: an invented method fails right away.
- The license key is applied: it must be set before the first IronBarcode call, or that call throws
LicensingException. - Each API method exists: consult the API reference for any unfamiliar method before seeking alternatives.
- Every barcode can be read: decode each generated image with
BarcodeReaderorGeneratedBarcode.Verifyand compare the result to the input.
The fourth check exists because the compiler cannot detect an unreadable barcode.
Be aware of the following common issues in generated IronBarcode code:
- The wrong package name: the opening paragraph covers this, and it remains the most repeated mistake.
- Enum casing inconsistencies:
BarcodeEncoding.DatabarandBarcodeWriterEncoding.DataBarbelong to different enums and differ by one capital letter. - Methods borrowed from other barcode libraries: a model may combine APIs from several sources into methods that do not exist.
- Invented reader options: check any unfamiliar option against the reading speed options and crop region guides.
Let the Agent Verify Its Own Work
An agent can perform all four checks independently. Request evidence for each check rather than a summary.
Build and run the project in Release mode. Confirm that every IronBarcode member used
appears in the documentation, that IronBarCode.License.IsLicensed returns true, and
that every barcode you generated reads back to the value you wrote. Report the build
result and a table of written value, read value, and format from the run itself.
A Result You Can Reproduce
This section evaluates an agent using a realistic task and a single prompt, with no code provided by you. Run it in a new session on an empty project and judge the outcome against the criteria below.
The prompt
Build a .NET 9 minimal API for shipping labels with two endpoints: GET /label/{trackingNumber} returns a Code 128 PNG with the value printed below the bars, and POST /scan accepts an uploaded image and returns every barcode it contains as JSON (value and format). Work start to finish alone: write, build, run, and fix, making sensible assumptions where anything is unspecified. Save every deliverable to the project root.
1. Install the BarCode NuGet package pinned to version 2026.9.2.
2. Read from https://ironsoftware.com/barcode/csharp/llms.txt and the pages it links to, using only APIs documented there.
3. Read the license key from the IRONBARCODE_LICENSE_KEY environment variable at startup. If IronBarCode.License.IsLicensed is false, stop and report that instead of continuing.
4. Generate a test set of 12 barcodes into a testset folder: 4 Code 128 tracking numbers, 3 QR codes carrying order URLs, 3 DataMatrix codes carrying GS1 element strings, and 2 EAN-13 codes with correct check digits. Name each PNG after its format and index.
5. Implement /scan with BarcodeReaderOptions narrowed to those four formats and ExpectMultipleBarcodes enabled.
6. Build in Release, run the API, call /label for one tracking number, then POST every testset image and the /label output to /scan.
7. Write roundtrip.md: a table of file, written value, read value, format, and match. All 13 must match; if any do not, fix the cause and run again.
8. Finish with a short report: build result, match count, and assumptions made.
Output
This is the original PNG returned by GET /label/1Z999AA10123456784 during the recorded run. The round-trip table from the same run lists all 13 images with their written and decoded values.
What passes
- The Release build completes without manual intervention.
roundtrip.mdshows 13 of 13 matching rows, each read value matching what was written and each format correct.- Both EAN-13 values carry valid check digits, and the GS1 strings come back unchanged.
- The license key comes from the environment and appears nowhere in source or in
roundtrip.md.
The run record
| Item | Value |
|---|---|
| Package | BarCode 2026.9.2 |
| Target framework | .NET 9 |
| Agent and model | Claude Code, Opus 5 |
| Machine | Windows 11 x64, Intel Core i9-14900KF, 64 GB RAM |
| Result | Release build passed, 13 of 13 round trips matched |
| Reference output | label.png, roundtrip.md |
| Last tested | September 16, 2026 |
One compilation fix was required during the run, and no code was manually edited.
Agent-Specific Guides
The setup above works with any of them. Each guide below adapts it to one tool:
- Use IronBarcode with Claude Code.
- Use IronBarcode with ChatGPT Codex.
- Use IronBarcode with GitHub Copilot.
- Use IronBarcode with Cursor.
- Use IronBarcode with Google Antigravity.
Troubleshooting
- Apply a License Key in IronBarcode covers every way to set the key when the first barcode call throws.
- Barcode Not Recognized works through a symbol that writes but will not decode.
- IronBarcode NuGet Packages lists which package belongs on which platform.
Questions?
If you have any questions, reach out to support@ironsoftware.com
Curtis Chau holds a Bachelor’s degree in Computer Science (Carleton University) and specializes in front-end development with expertise in Node.js, TypeScript, JavaScript, and React. Passionate about crafting intuitive and aesthetically pleasing user interfaces, Curtis enjoys working with modern frameworks and creating well-structured, visually appealing manuals.