> ## Documentation Index
> Fetch the complete documentation index at: https://wb-21fd5541-sdk-testing-latest.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# How do I save code?‌

Saving code with each run helps you reproduce experiments and track which version of your code produced a given result. Use `save_code=True` in `wandb.init` to save the main script or notebook that launches the run. To save all code for a run, version the code with W\&B Artifacts. The following example demonstrates this process:

```python theme={null}
code_artifact = wandb.Artifact(type="code")
code_artifact.add_file("./train.py")
wandb.log_artifact(code_artifact)
```

***

<Badge stroke shape="pill" color="orange" size="md">[Artifacts](/support/models/tags/artifacts)</Badge>
