Ember

From j4flmao/agent-skills · View interactive version

Ember is an AI agent skill from the GitHub repository j4flmao/agent-skills. Use when the user asks about Ember.js, Ember CLI, Ember Octane, Glimmer components, tracked properties, Ember routes and services, or Ember Data / WarpDrive. Produces convention-driven Ember code and data-layer setup. Not for React, Vue or Angular apps (use react-architecture, vue-architecture or an

How to use this skill

Skill file

Ember.js

Purpose

Build ambitious web applications using Ember's convention-over-configuration approach — Ember CLI for scaffolding, Ember Data for state management, and Octane-era patterns for modern components.

Version Note (2026)

Ember Data is now published as WarpDrive (@warp-drive/*); the ember-data package is meant for maintaining existing apps, and recent Ember releases use WarpDrive packages directly. Concepts (store, models, request handling) carry over; check the installed package before writing imports.

Agent Protocol

Trigger

Exact user phrases: "Ember setup", "Ember app", "Ember CLI", "Ember Data", "Ember Octane", "Ember component", "Ember route", "Ember service", "Ember project", "ember.js".

Input Context

Before activating, verify:

Output Artifact

No file output. Produces code snippets and structural guidance as text.

Response Format

Code with Ember conventions:

// app/routes/index.ts
import Route from '@ember/routing/route'
import { service } from '@ember/service'

No preamble. No postamble. No explanations. Compress output — why use many token when few do trick.

Completion Criteria

Max Response Length

~4096 tokens.

Component Architecture / Decision Trees

Architecture Options

| Approach | Trade-off | When to Use |

|----------|-----------|-------------|

| Glimmer component (native class) | Full lifecycle, tracked state | Interactive components with logic |

| Template-only (.hbs) | Zero JS, pure display | Static UI, presentational |

| Classic component | Legacy, deprecated | Old code, migration path only |

| Custom modifier | DOM interaction only | Event listeners, scroll handling |

| Helper function | Pure transformations | Formatting, math, string utils |

Component Type Decision

What is the component's purpose?
  Pure display (no logic, no state) -> Template-only component (.hbs only)
  Display with local state -> Glimmer component (native class + @tracked)
  Encapsulated behavior + template -> Classic component (deprecated, avoid)
  Reusable DOM interaction -> Custom modifier (use:)
  Contextual helper -> Helper function (pure, no state)

State Management Decision

Where does the data live?
  Per-component, ephemeral -> @tracked property on the component
  Shared across routes -> Route model hook + service caching
  Global application state -> Service (@service injection)
  Persisted server data -> Ember Data store (this.store.findAll)
  URL state -> Query params on controller

Data Loading Decision

Where is the data needed?
  Single route -> model() hook in route
  Multiple routes sharing data -> Parent route model + modelFor on child
  Global (user, session) -> Service loaded in application route
  Lazy / on-demand -> this.store.findRecord in component (Octane)
  Real-time -> Ember Concurrency or tracked tasks

Component Design Patterns

Route with Model Hook

// app/routes/posts.ts
import Route from '@ember/routing/route'
import { service } from '@ember/service'

export default class PostsRoute extends Route {
  @service declare store: Store

  async model(params: { page: string }) {
    const page = parseInt(params.page) || 1
    return this.store.findAll('post', { page })
  }
}

Glimmer Component with Tracked

// app/components/post-card.ts
import Component from '@glimmer/component'
import { tracked } from '@glimmer/tracking'
import { action } from '@ember/object'

interface Args {
  post: Post
  onSelect: (id: string) => void
}

export default class PostCard extends Component<Args> {
  @tracked isExpanded = false

  get excerpt() {
    return this.args.post.body.length > 100
      ? this.args.post.body.slice(0, 100) + '...'
      : this.args.post.body
  }

  @action
  toggleExpand() {
    this.isExpanded = !this.isExpanded
  }

  @action
  select() {
    this.args.onSelect(this.args.post.id)
  }
}
{{! app/components/post-card.hbs }}
<article class="post-card">
  <h2>{{@post.title}}</h2>
  <p>{{if this.isExpanded @post.body this.excerpt}}</p>
  <button type="button" {{on "click" this.toggleExpand}}>
    {{if this.isExpanded "Show less" "Show more"}}
  </button>
</article>

Template-Only Component

{{! app/components/ui/button.hbs }}
<button class="btn btn--{{@variant}}" type="button" ...attributes>
  {{yield}}
</button>

Service with Ember Data

// app/services/post-store.ts
import Service from '@ember/service'
import { service } from '@ember/service'
import { tracked } from '@glimmer/tracking'

export default class PostStoreService extends Service {
  @service declare store: Store
  @tracked currentPostId: string | null = null

  get currentPost() {
    return this.currentPostId
      ? this.store.peekRecord('post', this.currentPostId)
      : null
  }

  async findByTag(tag: string) {
    return this.store.query('post', { tag })
  }

  async createPost(data: Partial<Post>) {
    const post = this.store.createRecord('post', data)
    await post.save()
    return post
  }
}

Custom Modifier

// app/modifiers/click-outside.ts
import Modifier from 'ember-modifier'

interface Args {
  positional: []
  named: { action: () => void }
}

export default class ClickOutsideModifier extends Modifier<Args> {
  private handler: ((e: MouseEvent) => void) | null = null

  didReceiveArguments() {
    this.handler = (e: MouseEvent) => {
      if (!this.element.contains(e.target as Node)) {
        this.args.named.action()
      }
    }
    document.addEventListener('click', this.handler, true)
  }

  willRemove() {
    if (this.handler) {
      document.removeEventListener('click', this.handler, true)
    }
  }
}

State Management Patterns

Ember Data Store

// Fetching
const posts = await this.store.findAll('post')
const post = await this.store.findRecord('post', id)
const results = await this.store.query('post', { category: 'tech' })

// Creating
const post = this.store.createRecord('post', { title: 'New', body: '...' })
await post.save()

// Updating
post.title = 'Updated'
await post.save()

// Deleting
await post.destroyRecord()

Service-Based State

Services are singletons injected with @service. Use @tracked for reactive properties:

@service declare auth: AuthService
@service declare cart: CartService

// In template: {{this.auth.user.name}}

URL State via Query Params

// app/controllers/posts.ts
import Controller from '@ember/controller'
import { tracked } from '@glimmer/tracking'

export default class PostsController extends Controller {
  @tracked page = 1
  queryParams = ['page']
}

Performance Optimization

Rendering Performance

Bundle Size

Optimization Techniques

Build & Bundle Considerations

Testing Strategies

Component Tests

// tests/integration/components/post-card-test.ts
import { module, test } from 'qunit'
import { setupRenderingTest } from 'ember-qunit'
import { render, click } from '@ember/test-helpers'
import { hbs } from 'ember-cli-htmlbars'

module('Integration | Component | post-card', function (hooks) {
  setupRenderingTest(hooks)

  test('it toggles expanded state', async function (assert) {
    this.set('title', 'Test Post')
    this.set('body', 'Test body')
    await render(hbs`<PostCard @title={{this.title}} @body={{this.body}} />`)
    assert.dom('article').exists()
    await click('h2')
    assert.dom('p').hasText('Test body')
  })
})

Route Tests

module('Acceptance | posts', function (hooks) {
  setupApplicationTest(hooks)

  test('visiting /posts loads data', async function (assert) {
    await visit('/posts')
    assert.dom('[data-test-post]').exists({ count: 10 })
  })
})

Key Testing Practices

Migration Patterns

Classic (v3.14-) to Octane (v3.15+)

| Classic | Octane |

|---------|--------|

| EmberObject.extend() | Native class extends Component |

| computed() | @tracked + getter |

| .observes() | @tracked + @action |

| didInsertElement | {{did-insert}} modifier |

| this.set('prop', val) | this.prop = val |

| {{my-component}} | <MyComponent /> |

| this._super() | No equivalent (native class) |

| Ember.Component | @glimmer/component |

Migration order: 1) Update Ember CLI to v3.15+, 2) Convert components one by one, 3) Replace computed with @tracked, 4) Replace observers with native getters, 5) Use ember-cli-update for automated migration.

From React to Ember

| React Pattern | Ember Equivalent |

|---------------|------------------|

| useState | @tracked property |

| useEffect | Modifiers ({{did-insert}}, {{did-update}}) |

| useContext | @service injection |

| Props | @arg (named args in .hbs template) |

| JSX | Handlebars (.hbs) templates |

| React.memo | Template-only component (no JS class) |

Anti-Patterns

  1. Using classic components for new code: Always use Glimmer components.
  2. Mutating @tracked with set(): set() is for classic mode. Octane uses this.property = value.
  3. Over-nesting routes: Each nesting adds a template + controller + route file.
  4. Missing outlet in layout templates: Child routes won't render without {{outlet}}.
  5. Service as a data dump: Services should encapsulate logic.
  6. Direct DOM manipulation: Use modifiers or {{did-insert}} instead of lifecycle hooks.
  7. Not using ember-concurrency for async: Raw promises in @tracked cause memory leaks.
  8. Over-using observers: Use @tracked + getters/computed.

Common Pitfalls

  1. Missing outlet in layout templates — {{outlet}} is required for child routes.
  2. Forgetting to import types — Ember's TS support requires explicit type imports.
  3. Using classic components for new code — always Glimmer.
  4. Mutating @tracked with set() — use this.prop = value.
  5. Service as a data dump — encapsulate logic in services.
  6. Direct DOM manipulation in components — use modifiers.

Compared With

| Aspect | Ember | React | Vue |

|--------|-------|-------|-----|

| Architecture | Convention over config | Library + choices | Framework |

| Build tool | Ember CLI | Vite/CRA | Vite/Vue CLI |

| State mgmt | Ember Data + Services | Zustand/Redux | Pinia/Vuex |

| Templating | Handlebars (.hbs) | JSX/TSX | .vue SFC |

| Routing | Built-in, config | React Router | Vue Router |

| TypeScript | First-class since v4 | Optional | Via vue-tsc |

| Learning curve | Steep | Moderate | Moderate |

Ecosystem & Tooling

  1. Ember CLI — ember generate component, ember generate route
  2. Ember Inspector browser extension
  3. ember-cli-mirage — API mocking
  4. ember-concurrency — async task management
  5. ember-truth-helpers — boolean template helpers
  6. ember-composable-helpers — functional helpers
  7. ember-test-selectors — data-test-* stripped from production
  8. ember-cli-update — automated migration
  9. ember-template-lint — template linting
  10. ember-cli-bundle-analyzer — bundle analysis

UI Libraries

Rules

References

Handoff

No artifact produced.

Next skill: ember-data (if complex data layer) or frontend-testing.

Carry forward: route/service pattern, Glimmer component conventions, @tracked/@action.

Architecture Decision Trees

Component Strategy Decision Tree

Does the component need lifecycle hooks or DOM access?
  ├── No  → Template-only component (Glimmer) - fastest, no JS class
  └── Yes → Does it manage state shared across components?
       ├── Yes → Service + component pattern
       └── No  → Classic Glimmer component with @tracked
            Is the DOM interaction imperative (drag/drop, canvas)?
            ├── Yes → Use modifier (ember-modifier)
            └── No  → Use component lifecycle (constructor, willDestroy)

Routing Strategy Decision Tree

Is the route data-driven (model-dependent)?
  ├── No  → Static route with template content
  └── Yes → Does the model come from API?
       ├── Yes → Route model() hook with ember-data or fetch
       └── No  → Route model() with local computation
            Are there multiple async dependencies?
            ├── Yes → RSVP.hash() in model() with parallel loading
            └── No  → Single async model() return

Security Considerations

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.