/symfony:prg-patternfrom symfony
Implements the Post/Redirect/Get pattern for form handling to prevent duplicate submissions on page refresh. Covers POST success redirects, POST error re-renders, and flash messages.
Ships in symfony. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
POST success -> redirect. POST error -> re-render with errors. This prevents duplicate submissions on page refresh.
┌─────────────────────────────────────────────────────────────┐
│ PRG FLOW │
├─────────────────────────────────────────────────────────────┤
│ │
│ GET /form ──────────► Display Form │
│ ▲ │ │
│ │ ▼ │
│ │ User fills & submits │
│ │ │ │
│ │ ▼ │
│ ┌────┴────┐ POST /form │
│ │ Refresh │ │ │
│ │ safe! │ ▼ │
│ └────┬────┘ ┌──────────┴──────────┐ │
│ │ │ │ │
│ │ Validation OK? Validation KO │
│ │ │ │ │
│ │ ▼ ▼ │
│ │ 302 REDIRECT Re-render form │
│ │ │ with errors │
│ │ ▼ │
│ └──── GET /success │
│ │
└─────────────────────────────────────────────────────────────┘
if ($request->isMethod('POST')) {
$selection = $request->request->getString('choice');
if ($this->isValid($selection)) {
// ✅ Success: REDIRECT (never return HTML)
return new RedirectResponse(
$this->urlGenerator->generate('next_step')
);
}
// ❌ Error: Re-render form (no redirect)
return $this->render(..., hasError: true);
}
When validation fails, re-render the form with error messages. This is NOT a violation of PRG because:
When redirecting after success, use flash messages:
// In controller
$this->session->getFlashBag()->add('success', 'Operation completed');
return new RedirectResponse(...);
// In template
{% for message in app.flashes('success') %}
<div class="alert alert-success">{{ message }}</div>
{% endfor %}
#[Route(path: '/form', name: 'my_form', methods: ['GET', 'POST'])]
public function __invoke(Request $request): Response
{
if ($request->isMethod('POST')) {
$data = $request->request->all();
if (!$this->validate($data)) {
// Error: re-render with data
return $this->render($data, hasError: true);
}
// Success: process and redirect
$this->process($data);
return new RedirectResponse(
$this->urlGenerator->generate('success_page')
);
}
// GET: display empty form
return $this->render();
}
| Scenario | Response | Why |
|---|---|---|
| GET request | Render form | Display form |
| POST + valid | RedirectResponse | PRG: prevent re-submit |
| POST + invalid | Render with errors | Show validation errors |
| POST + exception | Render with error | Show error message |
// ❌ WRONG: Returning HTML after successful POST
if ($valid) {
$this->save($data);
return new Response('Success!'); // Refresh will re-submit!
}
// ❌ WRONG: Redirecting on error (loses user input)
if (!$valid) {
return new RedirectResponse('/form?error=1');
}
// ✅ CORRECT
if ($valid) {
$this->save($data);
return new RedirectResponse('/success');
}
return $this->renderWithErrors($data);
What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
5 skills in this plugin
/symfony-formACTIVATE when working with Symfony FormTypes, form handling, data_class, DataTransformers, form options, or property_path. ACTIVATE when creating or modifying any FormType class. Covers: data_class as single source of truth (no data in options), DataTransformer placement (not controller), property_path for collection mapping. DO NOT use for: form submission flow/PRG (see symfony:prg-pattern), form validation rules, general Symfony questions./symfony-frontendACTIVATE when adding or modifying frontend behaviour in a Symfony project — any new feature whose Twig template would otherwise contain inline script or style blocks, or any new JS/CSS file to load for a specific page. ACTIVATE for 'inline script in twig', 'inline style in twig', 'WebpackEncore', 'addEntry', 'encore_entry_link_tags', 'encore_entry_script_tags', 'where to put my JS', 'how to load CSS for one page', 'FormType injecting class', 'js- hook in template'. Covers: forbidden inline script/style tags in Twig, one Encore entry per feature, per-page asset loading via stylesheets/javascripts blocks extending parent, SCSS imported by the JS module (one entry bundles both), FormType stays domain/server (no CSS-only classes via `attr`), `js-*` hooks added at render time. DO NOT use for: jQuery style (see jquery:jquery), Twig conventions (see symfony:twig-conventions), FormType conventions (see symfony:symfony-form), autonomous visual debugging (see frontend:frontend-best-practices)./symfony-test-conventionsACTIVATE when writing or modifying a test that boots Symfony — WebTestCase, KernelTestCase, TypeTestCase, functional/interface tests, FormType tests, or container service doubles. ACTIVATE for 'crawler', 'assertSelectorTextContains', 'assertResponseRedirects', 'assertSelectorExists', 'followRedirect', 'disableReboot', 'getContainer() set', 'TypeTestCase', 'functional test', 'test fonctionnel', 'test d'interface'. Covers: which base class to pick, built-in WebTestCase assertions over hand-rolled crawler reads, one-dataset-one-test for HTML pages, full-JSON assertion for API endpoints, FormType testing, and container-double traps. DO NOT use for: PHPUnit/Prophecy patterns independent of Symfony — doubles, data providers, test naming, factories (see phpunit:php-test-conventions), TDD workflow (see phpunit:php-tdd-workflow), FormType design itself (see symfony:symfony-form)./twig-conventionsACTIVATE when writing or modifying Twig templates, using Twig components (twig:*), handling translations in Twig, debugging translation issues, or deciding whether to create a Twig component. ACTIVATE whenever 'trans_default_domain', 'twig component', 'translation not working', 'create twig component', or 'should I create a component' appears. Covers: trans_default_domain isolation in Twig components (1 translation = inline domain, 2+ translations = hoist trans_default_domain in the component scope), ClockInterface for dates in templates, when to create a Twig component vs use direct HTML. DO NOT use for: Twig syntax basics, Symfony controller rendering, generic CSS questions.npx claudepluginhub fabiensalles/claude-marketplace --plugin symfony