Symfony Console commands follow a specific pattern — #[AsCommand], configure(), execute(), argument definitions, styled output. Claude knows the entire API and can scaffold a production-ready command from a description.
Create a Symfony Console command that:
- Is named app:sync-products
- Accepts an optional --dry-run flag
- Fetches products from an external HTTP API
- Upserts them into a Doctrine repository
- Shows a ProgressBar and a summary Table at the end
- Logs errors without halting the entire run
Claude will generate a fully wired command class using #[AsCommand], Symfony's ProgressBar, Table, and SymfonyStyle output helpers, and a clean separation between fetching, processing, and persisting. It handles constructor injection for services like HttpClientInterface and LoggerInterface correctly.
#[AsCommand(name: 'app:sync-products', description: 'Sync products from the external API')]
class SyncProductsCommand extends Command
{
public function __construct(
private readonly HttpClientInterface $http,
private readonly ProductRepository $products,
private readonly LoggerInterface $logger,
) {
parent::__construct();
}
// ...
}
Follow up with "add a --batch-size option" or "write a PHPUnit test that mocks the HTTP client" to flesh out the command further.
Symfony commands have a lot of boilerplate — Claude handles all of it so you can focus on the actual logic.
Log in to leave a comment.
The /security-review command scans your uncommitted changes for injection vectors, auth gaps, hardcoded secrets, and other common vulnerabilities.
The SessionStart hook fires when any session begins or resumes, making it ideal for loading environment variables and running one-time setup scripts.
Ask Claude to write property-based tests for your functions using fast-check — it identifies the mathematical invariants in your code and generates tests that cover inputs you'd never enumerate by hand.