> ## Documentation Index
> Fetch the complete documentation index at: https://backstage.spotify.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Generate package metadata

> Use the Backstage CLI to generate valid package metadata for Portal plugins with missing or incomplete pluginIds and publish configuration.

If you have packages added to your Portal instance with missing or incomplete metadata,
and you are the owner of the package, you can use Backstage tooling to generate valid metadata for the package.

```bash theme={"theme":{"light":"github-light","dark":"dracula"}}
npx @backstage/cli repo fix --publish
```

To make sure the metadata is generated as part of publishing your package you can add a new script to your `package.json`.
Update your root `package.json` in your workspace with the following script to make sure metadata gets generated.
Make sure to run the `repo:fix` command before publishing your Backstage package.

```json title="package.json" theme={"theme":{"light":"github-light","dark":"dracula"}}
{
  "scripts": {
    "repo:fix": "backstage-cli repo fix --publish"
  }
}
```

When you generate metadata for your package, review what it generates to make sure `pluginIds` and other types of the metadata makes sense.
The CLI is trying to guess things based on `package name` and `role` of the package.
If it gets anything wrong you can update the field manually in the `package.json`
Note: There are some inconsistencies that it might reject but it'll give you some more info in that case.
