# Alt+Click any element in your Angular app and hand its origin to your coding agent

> Source: <https://dev.to/alexanderspies/altclick-any-element-in-your-angular-app-and-hand-its-origin-to-your-coding-agent-4773>
> Published: 2026-12-03 20:39:57+00:00

**Key takeaway:** ng-origin's Alt+Click copies a block naming the app component that declares an element, with file and line, plus library component, projection target and search anchors, giving coding agents the correct edit location; the Template line requires Angular 22.1.4+ with enableTemplateSourceLocations in a

Telling a coding agent which button you mean is weirdly hard. "The Archive button on the dashboard" sends it grepping for the label. In an app with a shared UI library it often ends up in the button component itself, not in the template where that particular button is declared.

ng-origin is a side project of mine that tries to fix this. Hold Alt (⌥ on a Mac) in your running dev app, click an element, and a plain-text block with its origin lands in your clipboard. Version 22.0.0 is the first release.

For the Archive button in a dashboard widget, the block looks like this:

```
Page: /dashboard · route dashboard → DashboardPage (src/app/dashboard/dashboard-page.ts:13)
Element: <button> "Archive"
Inside: UiButton <button ui-button> (ui-kit) · variant=primary
Declared in: Widget (src/app/widget/widget.ts:15)
Projected into: CardShell (src/app/card-shell/card-shell.ts:13)
Template: src/app/widget/widget.html:2
Find: widget.archive
Chain: Widget > DashboardPage
Context: lang=en · viewport=1440×900 (xl)
```

`Declared in` is the line I care about most. It names the app component whose template contains the button, with file and line. The library component (`UiButton`) and the card the button is projected into get their own lines, so they don't get mixed up with it. `Find` collects search anchors: translation keys, your app's CSS class, `data-testid`. Every value is read from the running app. Nothing is guessed.

Paste that into your agent, add "make this a secondary button", and it starts in the right file.

```
npm i -D ng-origin
js
// app.config.ts
import { ApplicationConfig, isDevMode } from '@angular/core';
import { provideNgOrigin } from 'ng-origin';

export const appConfig: ApplicationConfig = {
  providers: [isDevMode() ? [provideNgOrigin()] : []],
};
```

NgModule apps put the same provider into the root module. Every option is optional. `appPrefixes` tells it which CSS classes are yours, `libraries` maps selector prefixes like `ui-` to a package name, and there are `breakpoints`, a `context` callback (current role, language, whatever helps) and extra `redact` patterns.

With ngx-translate you get the translation keys through a ready-made resolver:

``` js
import { ngxTranslateTextKeys } from 'ng-origin/ngx-translate';

provideNgOrigin({ textKeys: ngxTranslateTextKeys() });
```

It compares the element's text with the translations already loaded for the current language, `{{param}}` placeholders included.

The `Template` line needs Angular 22.1.4 or later with `enableTemplateSourceLocations` in a development tsconfig. Without it, that one line is left out.

`modifier: 'ctrl-shift'` switches to Ctrl+Shift+Click.`window.ngOrigin.describe(element)` returns the block without copying it, which is handy in Playwright tests.
ng-origin makes no network requests and writes no storage. A block leaves the page only through your clipboard. Input values and the text of form fields are never read, and secret-shaped strings such as JWTs or API keys are replaced with `«redacted»` before anything is copied. That part is best-effort, so read a block before you paste it somewhere you don't trust.

Production builds drop the runtime and its strings. In dev it loads lazily as its own chunk after bootstrap.

So far only Chromium is tested, and only with a mouse. The peer range allows Angular 20 to 22, but my tests run on 20.3. It also relies on Angular's dev-mode debug API (`window.ng`), which can change between majors.

The major follows Angular. It's the newest Angular major ng-origin supports, so Angular 23 will bring ng-origin 23, and breaking changes wait for it.

Code and docs are on [GitHub](https://github.com/alexander-spies/ng-origin), the package is on [npm](https://www.npmjs.com/package/ng-origin), MIT licensed. If you're on Angular 21 or 22, I'd really like to hear whether it works for you.
