The phrase "add artifacts code build" usually means one of two things. If you're working in an AI chat product such as Claude, you add artifacts by enabling them in settings and asking for a self-contained piece of code or content; the chat then renders it in a side panel. If you're working in a software repository using an artifact system — a build output store, a package registry, or a CI artifact store — "adding artifacts" means publishing build outputs to that store so other jobs or people can download them. Both workflows are real, they use overlapping vocabulary, and the steps differ. The answer below covers both, with a short way to tell which one you need.
The first step in either case is to name your target: the chat interface's artifact panel, or your build system's artifact repository. Once you know which one you mean, the rest is a short, checkable sequence: confirm the tool supports it, enable it if needed, write the artifact so it is self-contained, trigger a build or render, verify the result, and only then wire it into anything else.
Deciding which "artifacts" you mean
"Artifact" is one of those words that spread across tools until it meant almost anything produced by a process. In AI chat products, an artifact is a discrete, rendered piece of output — a code file, a React component, a diagram, a document — that appears beside the conversation instead of inside it. In build and DevOps tooling, an artifact is the compiled or packaged output of a pipeline: a jar, a wheel, a tarball, a container image, a test report.
The two are not related, but users often search for both with the same words. A quick discriminator:
You're inside a chat window and want a code block to become a live preview or a downloadable file. You need the chat's artifact feature. You have a repository, a CI configuration file, or a package manager and want outputs stored and shared. You need the build/artifact-store workflow. You're not sure: check whether the word "artifact" appears in the product's own settings or documentation. If it does, that product's meaning is the one you should follow, even if internet tutorials use the other sense.
From here, the guide splits. Read the section that matches your case; the later half covers the build-store version in more detail because it has more moving parts.
Part 1: Adding a code artifact in an AI chat interface
Chat products change their feature names and menu locations often, so treat these as the stable shape of the workflow rather than a pixel-perfect map. The principle — enable the feature, then ask for something that qualifies — holds across products.
Prerequisites
A chat product that offers artifacts. Not every plan or every model does, and some products gate it behind a paid tier or a toggle. A current browser or the desktop app; artifact panels render poorly in very old browsers. A clear idea of what you want rendered: a single HTML file, a React component, a chart, a Markdown document, or plain code you want to download.
Steps
1: Open the product's settings or feature menu and look for "Artifacts," "Canvas," or a similar rendering feature. Turn it on if it's off. Some products enable it by default and only show a toggle for certain models. 2: Start a new conversation, or continue one, and ask for the deliverable explicitly rather than vaguely. "Build a single-file HTML page that draws a bar chart from hardcoded data" is an artifact request; "write some chart code" may just produce a code block in the chat transcript. 3: Keep the request self-contained. Artifacts render best when the code doesn't depend on files the chat can't see. Inline your CSS and JavaScript in one HTML file, avoid fetching data from URLs you haven't confirmed are reachable, and state any library you want loaded from a CDN. 4: Watch for the render. When it works, the code appears in a side panel with a preview and usually a download or copy control. When it doesn't, you'll see the code only in the message body — that's your signal the feature is off, the model didn't classify the output as an artifact, or the output failed to render. 5: Iterate in the same thread. Ask for specific changes ("make the bars horizontal," "add a hover tooltip") and the artifact should update rather than spawn a new one. 6: Download or copy the final version before you close the thread. Artifact state lives with the conversation; if the conversation is deleted, moved, or the product changes its data handling, the panel may not be recoverable.
Checking success
Success looks like a rendered preview beside the chat that matches what you asked for, plus a working copy/download action. Failure has two common symptoms: no panel appears at all (feature disabled or not supported on your plan), or the panel appears but the preview is blank or shows an error (usually a bad dependency, a syntax error, or a browser restriction like blocked local file access). For a blank preview, ask the model to remove external dependencies first, then re-add them one at a time. If the panel never appears, check the settings toggle and the model selector before assuming the code is wrong.
A realistic use: you ask for a small budgeting calculator as a single HTML file. It renders, you notice the currency formatting is wrong, you ask for a fix, the panel updates, and you download the finished file. The whole exchange is a handful of turns. What you should not expect is that the artifact persists as a deployed website — it's a rendered preview, not hosting. If you need it live, export it and deploy it yourself.
Part 2: Adding build artifacts to a repository or CI system
This is the more consequential interpretation, and the one the rest of the guide develops. The goal: take the outputs of your build and make them available — to a later pipeline stage, to other developers, or to a release process.
Prerequisites
Before you add artifact steps, confirm four things: your CI system's name and version, whether it has a native artifact mechanism or relies on a generic object store, the exact paths your build writes to, and who needs to consume the artifacts. That last point decides the design. Artifacts consumed only by later jobs in the same pipeline can often be uploaded and downloaded within the run; artifacts consumed by people or by other repositories need a durable store with retention rules and access control.
You also want a clean, reproducible build. If your build writes into the source tree or depends on files left over from previous runs, your artifacts will be inconsistent, and no amount of upload configuration fixes that. Run the build once from a clean checkout and note exactly which directories changed.
Steps
1: Identify the output paths. After a clean build, list what the build produced: compiled binaries, packaged archives, generated documentation, test reports. Write the paths down precisely; "the dist folder" is not a path, dist/ and build/libs/ are. 2: Decide what belongs in the artifact. Ship the deliverable and anything needed to verify it — checksums, a manifest, test reports. Exclude caches, temporary files, secrets, and anything that can be regenerated cheaply. An artifact that contains a .env file or an API key is a security incident waiting to be archived. 3: Add an upload step to your pipeline configuration, placed after the build step and before any step that consumes the artifact. The exact syntax depends on the system: some use a declarative artifacts: block with path globs, others use a CLI command that pushes files to a named store. The universal rule is that the step must reference the same paths you identified in step 1, and it must run only if the build succeeded. 4: Give the artifact a stable, meaningful name and, if the system supports it, a version or build number. Names like app-linux-x64-1.4.2 are consumable; names like output are not, because the next person can't tell two builds apart. 5: Set retention. Most stores let you expire artifacts after a number of days or keep only the last N builds. Without a retention policy, artifact storage grows without bound and eventually costs money or hits a quota. 6: Add a download step where a later job or a person needs the artifact. In a pipeline, this is usually a fetch step that references the artifact by name and version from the same run. For humans, it's the store's UI or a documented command. 7: Run the pipeline and verify. A successful upload step is not proof the artifact is usable — it only proves files moved.
Checking success
Three checks catch most mistakes. First, download the artifact from the store and confirm its size and contents match what the build produced; compare a checksum if the store publishes one. Second, run the artifact in a clean environment — unpack it, execute it, or install it — because an artifact that only works next to the build's leftover files is broken. Third, confirm the consumer works: the later pipeline job fetches the right version, or a colleague on another machine can download and use it.
If the upload step fails, the usual causes in order of likelihood are a wrong path (the build wrote somewhere else), a glob that matched nothing (many systems silently upload zero files rather than erroring), a permission problem on the store, or a size limit. Start with the reversible checks: print the directory listing in the pipeline right before the upload step, and tighten the glob to exact files. If the artifact downloads but won't run, the cause is almost always a missing runtime dependency or a path baked into the build — that's a build configuration issue, not an artifact issue.
What "code build" adds to the picture
The phrase "code build" in the query matters because artifacts are only as good as the build that produces them. A few build-side conditions determine whether artifact upload is straightforward or a constant source of confusion.
Reproducibility first. If two runs of the same commit produce different artifacts — because of timestamps, embedded build IDs, or dependency versions resolved at build time — then "which artifact is the release?" becomes unanswerable. Pinning dependency versions and normalizing embedded metadata fixes most of this. You don't need bit-for-bit reproducibility to start, but you do need to know which differences are expected.
Deterministic output paths second. Many build tools default to output directories that include the version or the platform, so the path changes between builds. Either configure a stable output directory or use glob patterns that match all variants and name the artifacts by their contents.
Build caching third. If your CI caches intermediate build state, make sure the cache is not being uploaded as part of the artifact. Caches are large, machine-specific, and useless to consumers. The fix is usually a tighter artifact path, not a cache change.
Finally, separate build from package. Building produces files; packaging produces a distributable. If consumers need an installable package, add a packaging step and upload that, not the raw build tree. Uploading both is fine if the store allows it, but the packaged artifact should be the one consumers are pointed to.
Artifact stores compared: what the main options actually differ on
There's no universal winner here; the right store depends on your pipeline and where consumers live. The comparison below uses equivalent criteria — location, access model, retention, and who typically uses it — and avoids version-specific claims, since these tools change.
| Store type | Where it lives | Access model | Retention | Best fit |
|---|---|---|---|---|
| CI-native artifact store | Inside the CI system | Pipeline-scoped by default | Configurable, often days | Later jobs in the same pipeline |
| Package registry | A registry service | Versioned packages with auth | Long-lived by design | Libraries and installable packages |
| Object storage bucket | Cloud storage | Bucket policies and IAM | Lifecycle rules you set | Large binaries, cross-team sharing |
| Container registry | A registry service | Image tags with auth | Tag- and digest-based | Deployable services |
The trade-off is consistent across rows: the closer the store is to your pipeline, the easier the wiring and the shorter the useful life; the further away, the more setup and governance it needs, and the longer artifacts persist. A team that only needs to pass a binary from build to test should use the CI-native store and not build a registry. A team publishing a library should use a package registry because consumers expect versioned installs. Mixing the two — dumping a release package into a CI store with 30-day retention — is a common mistake that bites when someone needs the release six weeks later.
One more distinction worth making: artifact stores hold outputs, while caches hold intermediate state. They often live in the same product and look similar, but caches are disposable and artifacts are not. If your store's UI has separate sections for the two, put files in the right one.
Worked example: a small build with a stored artifact
Consider a tiny project that compiles a command-line tool and runs a test suite. The pipeline has three jobs: build, test, release. The build job compiles to out/tool and runs unit tests that write a report to out/reports/. The test job needs the binary to run integration tests. The release job, run manually, needs the binary plus the report.
A workable design: the build job uploads out/tool and out/reports/ as one artifact named tool-$BUILD_NUMBER. The test job downloads that artifact by name and runs the binary. The release job downloads the same artifact and attaches both files to the release. Retention is set to 14 days for ordinary builds and longer for tagged releases, if the system allows per-tag rules. The build cache — intermediate object files — is never uploaded.
What could go wrong, and what each failure tells you:
The test job downloads an empty artifact. The build's glob matched nothing because the compiler writes to build/out/ on this platform. Fix: print the tree before upload and correct the path. The test job downloads the right binary but it won't execute. The binary was built for a different architecture than the test runner. Fix: build the test binary on the same platform, or use a cross-compile target that matches. The release job can't find an artifact from last month. Retention expired it. Fix: set tag-based retention before you need it, not after. A colleague downloads the artifact and it runs, but produces different output than in CI. The artifact embedded a path or a config file specific to the CI environment. Fix: make the build read configuration at runtime, not bake it in.
The arithmetic here is simple but worth stating: three jobs, one artifact name, two consumer paths. Every additional consumer adds a download step and a permission question, so keep the artifact set small and named clearly.
Common failure modes and what they actually mean
Most "artifact build" problems are one of five things, and the symptom usually points at the cause.
The artifact is missing entirely. Either the upload step never ran (it was skipped, conditional, or placed after a failure) or it uploaded nothing (empty glob). Check the pipeline log for the upload step specifically; a green overall build can hide a step that uploaded zero files.
The artifact is stale. The consumer fetched a cached or previously stored copy rather than the fresh one. This happens when names aren't versioned and the store's "latest" pointer wasn't updated, or when the consumer's fetch step has its own cache. Version your artifact names.
The artifact is too large. Many stores impose size limits per file or per artifact. Split large outputs, compress archives, or move large binaries to object storage. If the build itself produces gigabytes, that's usually a sign the artifact path includes build intermediates.
The artifact leaks secrets. A config file or test fixture with credentials got included. This needs immediate rotation of any exposed credentials and a path fix; retention deletion of the artifact is not sufficient, because copies may already exist.
The artifact works in CI but not elsewhere. Missing runtime dependency, baked-in absolute path, or a platform-specific binary. Reproduce the consumer's environment in a check step and see what's absent.
The stop condition for all of this: if you're debugging a store's authentication or permissions model, or if the artifact contains credentials or regulated data, that's the point to involve whoever owns the store or your security team rather than iterating in the pipeline. Those are infrastructure and compliance questions, not build-configuration questions, and ad hoc fixes can widen access unintentionally.
Making artifacts last: naming, versioning, and retention
Artifacts that are easy to create but hard to find become noise. Three habits keep a store useful.
Name by content and identity, not by job. tool-linux-x64-1.4.2-b4821 says what it is and which build made it; build-output says nothing. If your CI system injects a build number automatically, use it in the name rather than relying on the store's internal ordering.
Version explicitly. Even if the store supports "latest," treat it as a convenience pointer, not the source of truth. Consumers should pin to a version or a build number so a later upload doesn't silently change what they get.
Set retention before you need it. Ordinary builds can expire quickly; release builds should persist. If the store only supports a single global retention period, consider uploading releases to a separate long-lived store rather than extending retention for everything. The cost of artifact storage is usually small relative to the cost of losing a release you can no longer rebuild because a dependency disappeared.
FAQ
Do I need artifacts if my pipeline runs everything in one job? No. If build, test, and deploy happen in a single job on a single machine, there's nothing to hand off. Artifacts become necessary when work is split across jobs or machines, or when a human needs the output.
Is a container image an artifact? It's a build output stored in a registry, so the same naming, versioning, and retention thinking applies. The difference is that container registries have their own tag and digest model, and "latest" there has the same caveat as anywhere else: pin by digest for anything that matters.
Can I add artifacts to a build that already failed? Some systems let a post-failure step upload logs and test reports even when the build failed, which is often the most useful artifact of all. Check whether your system supports "always run" or "on failure" uploads and put diagnostics there, not in the main artifact.
What's the difference between an artifact and a cache? A cache speeds up a later build and can be thrown away at any time; an artifact is an output someone depends on and should be reproducible from source. If you'd be upset to lose it, it's an artifact.
The short version: figure out which artifact system you're actually using, enable or configure it, write the artifact so it stands on its own, upload it with a stable name and a retention rule, and verify it in a clean environment before you point anyone at it. Both the chat-panel version and the build-store version follow that same arc, and almost every failure along the way is one of the five diagnosable cases above.