# Add Dependabot to a Lit Component Project

Yes. An agent reads a Lit project's package.json, writes a grouped .github/dependabot.yml for npm, validates it, records a green baseline and opens a PR.

[Run this on Rush](https://cloud.getrush.ai/run/add-dependabot/lit/). Opens the console with this prompt ready to send, in a Project that has your repository.

## What the agent does

A Lit component repository is mostly devDependencies, so the agent reads the manifest to see which of them Dependabot will move and which it will leave alone. In a project laid out like lit/lit-element-starter-ts, `package.json` has one runtime dependency, `lit` `^3.2.0`, and a long development list: `typescript` `~5.9.0`, `eslint` `^8.15.0` with `@typescript-eslint/parser` and `@typescript-eslint/eslint-plugin` `^5.25.0`, `lit-analyzer` `^1.2.1`, `prettier` `^2.6.2`, `@web/test-runner` `^0.15.0`, `@web/test-runner-playwright` `^0.9.0`, `@web/dev-server` `^0.1.31`, `@web/dev-server-legacy` `^1.0.0`, `@open-wc/testing` `^4.0.0`, `rollup` `^4.18.0` with its node-resolve, replace and terser plugins, `@11ty/eleventy` `^1.0.1`, `@custom-elements-manifest/analyzer` `^0.6.3`, `@webcomponents/webcomponentsjs` `^2.8.0` and `rimraf` `^3.0.2`. There is no lockfile in the repository and no `.github` directory at all, so there is no workflow to raise and nothing to run on a Dependabot pull request until one is added.

Without a lockfile, Dependabot has only ranges to edit: a release that already satisfies the range produces no pull request, and one outside it produces a pull request that rewrites the range in `package.json`. The agent checks each range against the registry to say what the first week will bring. `lit` at `3.3.3` and `rollup` at `4.66.0` sit inside their ranges, so nothing arrives for them. `eslint` at `10.13.0`, `prettier` at `3.9.10`, `typescript` at `7.0.2`, `@11ty/eleventy` at `3.1.7`, `rimraf` at `6.1.3`, `@open-wc/testing` at `5.0.0`, `lit-analyzer` at `2.0.3` and the `@web` packages, now at `1.0.0` for the test runner and dev server and `3.0.0` for the legacy plugin, are all outside theirs, so each would be a pull request on day one. The pull request lists this so the team is not surprised by the first batch.

The file the agent writes is `.github/dependabot.yml` with `version: 2` and one `npm` entry on `directory: "/"`, a weekly schedule, `versioning-strategy: increase` so the range itself moves, and `groups` that keep tools that must agree together: a `web` group for `@web/*`, a `lint` group for `eslint`, `@typescript-eslint/*`, `lit-analyzer` and `prettier`, a `rollup` group for `rollup` and `@rollup/*`, a `docs` group for `@11ty/*`, and a `minor-and-patch` group with `update-types` limited to minor and patch for everything else, so `lit` itself arrives alone when it crosses a major. `open-pull-requests-limit` and a `commit-message` prefix are set, and a comment notes that a major `typescript` bump should be read alongside `lit-analyzer` and the `ts-lit-plugin` entry in `tsconfig.json`, since both lean on the compiler's API. No `github-actions` entry is written because there are no workflows; the comment says to add one when CI lands.

Then the agent proves the baseline it is about to disturb. It runs `npm install`, which has no lockfile to honour and so resolves the ranges fresh, then `npm run lint`, which chains `lit-analyzer` and `eslint 'src/**/*.ts'`, `npm run build`, which is `tsc` with `rootDir` `src` and `outDir` the repository root, and `BROWSERS=chromium npm run test:dev`, the subset `web-test-runner.config.js` allows through the `BROWSERS` variable so one Playwright browser is enough. It validates the YAML against the Dependabot v2 schema from SchemaStore, because an unknown key is ignored by GitHub rather than rejected. The pull request carries the three command outputs and the validation line; nothing in `package.json` or `src/` changes.

## Start it with one API call

`POST https://api.phoenix.so/o/{org}/sessions`

```json
{
  "agent": "claude",
  "input": "Add Dependabot to this Lit component project. Read package.json, tsconfig.json, web-test-runner.config.js, .eslintrc.json and .gitignore first, and note that there is no lockfile and no .github directory. Write .github/dependabot.yml with one npm entry on the root directory, weekly, versioning-strategy increase, and groups for @web/*, for eslint plus @typescript-eslint/* plus lit-analyzer plus prettier, for rollup plus @rollup/*, for @11ty/*, and a minor-and-patch group for everything else. Set open-pull-requests-limit and a commit-message prefix, and add a comment about reviewing a major TypeScript bump together with lit-analyzer and ts-lit-plugin. Check each range in package.json against the npm registry and list in the pull request which packages will get a pull request in the first week and which will not. Validate the file against the Dependabot v2 JSON schema, run npm install, npm run lint, npm run build and BROWSERS=chromium npm run test:dev, and open a pull request with those outputs. Do not change package.json.",
  "resources": [
    {
      "url": "https://github.com/your-org/your-app"
    }
  ]
}
```

1. **Get an API key.** In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
2. **Send the request.** POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
3. **Read what came back.** Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.

## What comes back

The pull request adds one file, `.github/dependabot.yml`, and its description has two lists: the packages whose current release is outside their range and will arrive as pull requests in the first week, grouped as the file groups them, and the packages inside their range that will stay quiet. Below that are the schema validation line and the output of `npm run lint`, `npm run build` and the Chromium test run from the sandbox.

GitHub reads the file once it lands on the default branch. Because the repository has no workflow, Dependabot's pull requests arrive with no checks; the pull request says so and points at adding a CI workflow first, so that each dependency bump runs the same lint, build and test commands the agent ran. The run's record keeps the baseline output for comparison with that first batch.

Before merging, a reviewer picks the schedule day and timezone, decides whether the first-week list is more than the team wants to review at once and lowers `open-pull-requests-limit` if so, and whether to hold `typescript` on its current major with an `ignore` rule until the analyzer is known to support the next one.

## Run it on every npm repository without Dependabot

An organisation with many component libraries starts one run per repository from its own server: one `POST /o/{org}/sessions` each, with the repository in `resources` and a `request_id` that is a UUID v5 of the repository's full name, so a retry returns the run already started. Each run reads its own manifest, so a repository with a `package-lock.json` gets lockfile-only updates described in its pull request, a monorepo gets one entry per workspace directory, and one with workflows gets a `github-actions` entry as well.

A team that wants the file to stay complete runs this prompt monthly from an automation with a `schedule` trigger in the Project that holds the repository. When a `.github/workflows` directory or a second `package.json` has appeared since the last run, that run opens a pull request adding the missing entry; otherwise it ends without a pull request and says what it checked.

## Why run it on Rush?

The file is short and the mistakes are quiet: a key Dependabot does not know is ignored, a missing `versioning-strategy` on a repository without a lockfile leaves pull requests that touch nothing, and a flat configuration turns the first week into a dozen separate pull requests for packages that only work when upgraded together. The agent checks the ranges against the registry, validates the file against the published schema and runs lint, build and tests once, so the first Dependabot pull request lands against a known baseline.

Every command stays with the run, including the Playwright browser install and the test run, and the pull request quotes them. Writing the same file for twenty component repositories costs no more attention than one, because each run has its own sandbox, its own registry lookups and its own pull request.

## Frequently asked questions

### Does Dependabot work without a lockfile?

Yes, but it can only edit the ranges in `package.json`, so a release that already satisfies a range produces nothing. That is why the agent sets `versioning-strategy: increase` and lists which packages are currently outside their range. Committing a lockfile later makes every release a pull request, and the same file keeps working.

### Why group the @web packages?

Because `@web/test-runner`, `@web/test-runner-playwright`, `@web/dev-server` and `@web/dev-server-legacy` are released together and `web-test-runner.config.js` imports from two of them. A pull request that raises one but not the others can fail on a mismatched plugin API, and a reviewer would spend time on a problem the group avoids.

### Will Dependabot's pull requests run my tests?

Only if a workflow exists, and this repository has none. The pull request says to add one that runs `npm run lint`, `npm run build` and `npm test`; until then each Dependabot pull request has to be checked out and run by hand, which is why the agent recorded the baseline output.

### Can the agent run Dependabot itself?

No. Dependabot runs on GitHub after the file is merged. What the agent proves is that the file is valid against the schema, what the first week's pull requests will be, and that lint, build and tests pass on the current versions. The first Dependabot pull requests are the real test.

## More Lit jobs

- [Add a Deploy Workflow for a Lit Component's Docs Site](https://getrush.ai/run/add-deploy-workflow/lit/)
- [Add GitHub Actions CI to a Lit Web Component Project](https://getrush.ai/run/add-github-actions-ci/lit/)
- [Add Localization to a Lit Web Component with @lit/localize](https://getrush.ai/run/add-i18n/lit/)

## The same job on other stacks

- [Set Up Dependabot for a Maven Project](https://getrush.ai/run/add-dependabot/maven/)
- [Add Dependabot to a Medusa Monorepo](https://getrush.ai/run/add-dependabot/medusa/)
- [Add Dependabot to an Express and Mongoose API](https://getrush.ai/run/add-dependabot/mongoose/)

## Keep reading

- [How a Rush run works on your repository, from request to pull request](https://getrush.ai/cloud/)
- [Compare cloud agents, agent sandboxes and AI code review](https://getrush.ai/compare/)
- [Rush pricing: Free, Pro and Max](https://getrush.ai/pricing/)
