agentleFS
custom-cardscustom-cards/button-card/.github/copilot-instructions.md

button-card

Copilot instructions2.5k starsChanged 8 years agoMITView on GitHub

CRITICAL: Always reference these instructions first and fallback to search or bash commands only when you encounter unexpected information that does not match the info here. Button Card is a TypeScript-based custom Lovelace card for Home Assistant. It provides customizable button elements with advanced styling, state management, and interaction capabilities.

We split this copilot-instructions.md into the rules it gives an agent

15 rules. About 1 is common, 4 are distinctive, and 10 are very specific to this project.

  • ≈1

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈4

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 10

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  • could be automatic: a setting could enforce it
  1. Distinctive:

    CRITICAL: Always reference these instructions first and fallback to search or bash commands only when you encounter unexpected information …

    line 3
  2. Very specific:

    Run linting: npm run lint -- takes ~2 seconds

    line 11
  3. Distinctive:

    NEVER CANCEL: All build commands must complete fully.

    line 14
  4. Very specific:

    Start development server: npm run watch -- runs on http://localhost:5000

    line 17
  5. Very specific:

    ALWAYS run npm run lint before committing changes or the CI (.github/workflows/ci.yml) will fail

    line 23
  6. Very specific:

    ALWAYS build and test your changes: npm run build followed by manual validation

    line 25
  7. Very specific:

    Run npm run lint to check code style

    line 76
  8. Very specific:

    Run npm run build to build and test compilation

    line 77
  9. Very specific:

    Start dev server with npm run watch to test changes

    line 78
  10. Distinctive:

    NO AUTOMATED TESTS: This project relies on manual testing and linting only

    line 88
  11. Very specific:

    Test environment: Use files in test/ directory with Home Assistant

    line 89
  12. Very specific:

    TypeScript errors: Check type definitions in src/types/

    line 125
  13. Common:

    Import errors: Verify module paths and ensure proper exports

    line 126
  14. Very specific:

    Dependency issues: Delete node_modules/ and run yarn install --frozen-lockfile

    line 127
  15. Distinctive:

    Must work within Home Assistant's Lovelace card framework

    line 148

≈ “Common” is an estimate: at least 1 in 5 of the 3,669 Copilot instructions files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
copilot-instructions.md

Button Card - GitHub Copilot Development Instructions

CRITICAL: Always reference these instructions first and fallback to search or bash commands only when you encounter unexpected information that does not match the info here.

Button Card is a TypeScript-based custom Lovelace card for Home Assistant. It provides customizable button elements with advanced styling, state management, and interaction capabilities.

Working Effectively

Bootstrap and Build

  • Install dependencies: yarn install --frozen-lockfile -- takes 10-60 seconds depending on cache. NEVER CANCEL. Set timeout to 120+ seconds.
  • Run linting: npm run lint -- takes ~2 seconds
  • Build the project: npm run build -- takes ~7 seconds (includes lint + rollup)
  • Build only (skip lint): npm run rollup -- takes ~5 seconds
  • NEVER CANCEL: All build commands must complete fully. Use timeout values of 120+ seconds for yarn install, 60+ seconds for builds.

Development Workflow

  • Start development server: npm run watch -- runs on http://localhost:5000
  • The dev server serves the built card at http://localhost:5000/button-card.js
  • Changes auto-rebuild and are served immediately
  • Access the built card via the development server for testing

Validation and Quality

  • ALWAYS run npm run lint before committing changes or the CI (.github/workflows/ci.yml) will fail
  • Format code: npx prettier --check src/**/*.ts (check) and npx prettier --write src/**/*.ts (fix)
  • ALWAYS build and test your changes: npm run build followed by manual validation
  • Security updates: npm run audit-fix - fixes known security vulnerabilities
  • CRITICAL VALIDATION: After making changes, ALWAYS test the card functionality by:
    1. Building the project: npm run build
    2. Starting the dev server: npm run watch
    3. Verifying the card loads at http://localhost:5000/button-card.js
    4. Testing basic card functionality if possible

Repository Structure

Key Directories

  • src/ - TypeScript source code
    • button-card.ts - Main card component (LitElement)
    • types/ - TypeScript type definitions
    • common/ - Shared utilities and helpers
    • helpers.ts - Utility functions for state, color, and entity management
    • styles.ts - CSS styling definitions
    • action-handler.ts - Event handling for user interactions
  • dist/ - Built output (generated, do not edit)
  • test/ - Home Assistant test environment configuration
  • .github/ - CI/CD workflows and GitHub configuration
  • examples/ - Example configurations and images

Important Files

  • package.json - Dependencies and npm scripts
  • rollup.config.js - Build configuration using Rollup bundler
  • tsconfig.json - TypeScript compiler configuration
  • .eslintrc.js - ESLint linting rules
  • .prettierrc.yaml - Code formatting rules
  • test/configuration.yaml - Home Assistant test configuration
  • test/ui-lovelace.yaml - Lovelace dashboard test configuration

Technology Stack

Core Technologies

  • TypeScript - Primary language
  • Lit (LitElement) - Web components framework for the card UI
  • Rollup - Module bundler and build tool
  • Home Assistant - Target platform (custom Lovelace card)
  • Web Components - Card is implemented as a custom element

Development Tools

  • ESLint - Code linting with TypeScript rules
  • Prettier - Code formatting
  • Yarn - Package management (lockfile: yarn.lock)
  • Node.js 22.x - Development environment (as per CI configuration)

Common Development Tasks

Making Code Changes

  1. Edit TypeScript files in src/
  2. Run npm run lint to check code style
  3. Run npm run build to build and test compilation
  4. Start dev server with npm run watch to test changes
  5. Validate card functionality manually

Adding New Features

  • Main card logic: Edit src/button-card.ts
  • Type definitions: Add to src/types/types.ts or related files
  • Styling: Update src/styles.ts
  • Utilities: Add to src/helpers.ts or src/common/

Debugging and Testing

  • NO AUTOMATED TESTS: This project relies on manual testing and linting only
  • Test environment: Use files in test/ directory with Home Assistant
  • The test environment includes mock entities and a sample Lovelace configuration
  • Manual testing workflow: Build → Start dev server → Test in Home Assistant or browser

Working with Home Assistant Integration

  • The card integrates with Home Assistant's Lovelace dashboard system
  • Entity management: Use functions in src/helpers.ts
  • State handling: Core logic in src/button-card.ts
  • Events and actions: Handled by src/action-handler.ts

Build System Details

Scripts Available

  • npm run build - Full build (lint + rollup)
  • npm run rollup - Bundle only (no linting)
  • npm run lint - ESLint validation
  • npm run watch - Development server with auto-rebuild
  • npm run audit-fix - Fix security vulnerabilities

Build Timing Expectations

  • yarn install: 10-60 seconds depending on cache (NEVER CANCEL - use 120+ second timeout)
  • npm run lint: ~2 seconds
  • npm run build: ~7 seconds (NEVER CANCEL - use 60+ second timeout)
  • npm run rollup: ~5 seconds
  • npm run watch: Starts in ~5 seconds, then watches for changes

CI/CD Pipeline

  • Located in .github/workflows/ci.yml
  • Runs on Node.js 22.x
  • Performs: yarn install → npm run lint → npm run build
  • Uses yarn with frozen lockfile for reproducible builds

Troubleshooting

Common Issues

  • Build failures: Usually linting errors - run npm run lint first
  • TypeScript errors: Check type definitions in src/types/
  • Import errors: Verify module paths and ensure proper exports
  • Dependency issues: Delete node_modules/ and run yarn install --frozen-lockfile

Performance Notes

  • The built card (dist/button-card.js) is ~190KB minified with source maps
  • Build process includes TypeScript compilation, bundling, and minification
  • Development server provides fast rebuilds with file watching
  • Comments are stripped during the build process for size optimization

Key Considerations

Generated Files (Do Not Edit)

  • dist/ - All files are generated by the build process
  • node_modules/ - Package dependencies (use yarn.lock for reproducible installs)
  • button-card.js.map - Source maps for debugging (generated with builds)

Code Style

  • Uses Prettier with specific configuration (single quotes, trailing commas, 120 char width)
  • ESLint enforces TypeScript best practices
  • Follows Lit/LitElement patterns for web components

Home Assistant Compatibility

  • Must work within Home Assistant's Lovelace card framework
  • Follows Home Assistant's custom card development patterns
  • Integrates with Home Assistant's state management and service calling

Version Management

  • Uses semantic-release for automated versioning
  • Main branch: master
  • Development branch: dev (open PRs against this)
  • Supports both stable and beta releases

REMEMBER: NEVER CANCEL long-running commands. Build processes may take several minutes. Always wait for completion and use appropriate timeout values (120+ seconds for installs, 60+ seconds for builds).

Download now (ZIP)

Trending

More talk lately.about the whole repository

Dec 2025: 0 mentionsJan 2026: 0 mentionsFeb 2026: 0 mentionsMar 2026: 0 mentionsApr 2026: 1 mentionMay 2026: 1 mentionJun 2026: 0 mentionsJul 2026: 1 mentionAug 2026: 0 mentionsSep 2026: 2 mentionsOct 2026: 5 mentionsNov 2026: 0 mentions
Dec 2025Jun 2026Nov 2026
Mentions a month of the custom-cards/button-card repository that our weekly crawl found. There is no adoption data for this file yet.

Who's talking about custom-cards/button-card

The biggest 5 of 25 mentions linking to the repository that our crawl found. Each line is their own headline.

See all 25

Talked about on GitHub and Bluesky (25 times).

On GitHub · 22

17 more on GitHub

On Bluesky · 3

  • Where files are headingNew Copilot instructions files have more rules about branches and pull requests, and fewer about code style.

    Of the Copilot instructions files we read, the 2,297 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

Reviews can't be read right now.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.