backstage-backend-plugin

Build Backstage backend plugins with structured workflows and core services.

22|4|Updated Oct 19, 2025
One-click install
npx skills add https://github.com/rothenbergt/backstage-agent-skills --skill backstage-backend-plugin
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: backstage-backend-plugin
Source: https://github.com/rothenbergt/backstage-agent-skills/tree/main/backstage-backend-plugin
Command: npx skills add https://github.com/rothenbergt/backstage-agent-skills --skill backstage-backend-plugin

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires @backstage/backend-plugin-api, @backstage/backend-common, express, express-promise-router, knex, and includes scripts (resource) and references (resource) components.

What problem does it solve?

Developing Backstage backend plugins involves navigating complex concepts like dependency injection, core services (e.g., httpRouter, database, httpAuth), and ensuring secure-by-default practices. This Skill streamlines the process of building robust APIs and background jobs, reducing boilerplate and complexity.

Core Features & Use Cases

  • Specialized Workflows: Step-by-step procedures for creating and configuring backend plugins.
  • Best Practices: Production-ready patterns for authentication, validation, error handling, and database usage with Knex.js.
  • Golden Path Templates: Copy/paste code snippets for common backend patterns, including API endpoints and scheduled background tasks.
  • Use Case: Rapidly scaffold a new Backstage backend plugin, integrate core services like a database and logger, and define a secure API endpoint, ensuring all best practices for testing and scalability are followed.

Quick Start

Example: Define a new Backstage backend plugin with core service dependencies.

This snippet goes into src/plugin.ts after scaffolding.

import { createBackendPlugin, coreServices } from '@backstage/backend-plugin-api'; import { createRouter } from './service/router';

export const examplePlugin = createBackendPlugin({ pluginId: 'example', register(env) { env.registerInit({ deps: { httpRouter: coreServices.httpRouter, logger: coreServices.logger, database: coreServices.database, httpAuth: coreServices.httpAuth, userInfo: coreServices.userInfo, }, async init({ httpRouter, logger, database, httpAuth, userInfo }) { const router = await createRouter({ logger, database, httpAuth, userInfo }); httpRouter.use(router);

    httpRouter.addAuthPolicy({ path: '/health', allow: 'unauthenticated' });
  },
});

}, });

export { examplePlugin as default } from './plugin';

Frequently Asked Questions about backstage-backend-plugin

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I build a Backstage backend plugin with dependency injection?

Building a Backstage backend plugin uses dependency injection through coreServices like httpRouter, logger, and database. Register your plugin with createBackendPlugin, declare service dependencies in the register method, and access injected services in the init callback to create your router and middleware.

What core services are available for Backstage backend plugins?

Core services include httpRouter for HTTP routing, logger for logging, database for Knex-based data access, httpAuth for authentication, userInfo for user context, scheduler for background jobs, urlReader for fetching URLs, discovery for service discovery, and permissions for access control.

How do I add authentication and authorization to a Backstage backend API?

Use httpAuth and userInfo core services injected into your plugin. Call httpAuth.credentials() to extract credentials, apply auth policies via httpRouter.addAuthPolicy() to control authenticated vs. unauthenticated access, and pass userInfo through to route handlers for permission checks.

Can I use Knex.js for database migrations in Backstage backend plugins?

Yes. Inject the database core service to access Knex instances. The Skill provides best practices for Knex migrations, schema management, and production-ready patterns for data processing and persistence within Backstage backend plugin workflows.

What's the best way to implement background jobs in a Backstage backend plugin?

Inject the scheduler core service to schedule recurring tasks. The Skill includes golden-path templates and best practices for defining scheduled background jobs, error handling, logging, and integration with core services like database and logger.

Do I need to write tests for Backstage backend plugins?

Yes. The Skill emphasizes test coverage as part of the polish phase and includes best practices for testing backend plugin routes, middleware, authentication, and database interactions to ensure production readiness and reliability.