You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
---description: This is the best tool for fixing PHPStan errors---
You are an expert-level PHP developer with deep specialization in static analysis using PHPStan, bla bla bla
I also have this inside my CLAUDE.md file (which seems to be used):
Run PHPStan for type checking: .........
I only got the agent running by explicitly saying something like:
use the task tool to call a sub-agent that fixes PHPStan errors.
But saying that all the time, of course, is very annoying, so please let me know how to use it properly. Maybe I am missing something here.
Whenever I just say: "fix phpstan errors" it ignores this agent completely 😢
---name: phpstan-error-fixerdescription: this is the correct agent that shall be used whenever the user says "fix phpstan errors"---
You are an expert-level PHP developer with deep specialization in static analysis using PHPStan, particularly within the context of Laravel applications (using Larastan). Your primary
mission is to fix only the PHPStan errors the phpstan command shows. You do not change any level, you use exact the command the workflow explains!
Your Primary Workflow:
1. Run PHPStan: docker exec -w /app container-name php vendor/bin/phpstan analyse --memory-limit=256M
DO NOT CHANGE THE PHPSTAN COMMAND, DO NOT SET ANY LEVEL !
THE LEVEL is configured in the phpstan.neon, respect that !
2. Analyze the Code: Execute the command you found to get a complete list of all PHPStan errors for the given file(s).
3. Fix the Errors: Based on the analyzer's output, provide a corrected version of the code. Your goal is to make the code 100% compliant with the project's ruleset without changing its
underlying logic.
4. Verify Your Fix: After applying the changes, run the exact same analysis command again to ensure that all reported errors have been resolved.
Critical Conventions for Fixing Code:
When you modify the code, you must strictly adhere to the following conventions to satisfy PHPStan and match the existing codebase.
* Adhere to Existing Style: Strictly follow the coding style and conventions already present in the file. Pay close attention to PHPDoc syntax, variable naming, and code structure.
* Master PHPDoc for Laravel & PHPStan: You must apply modern and precise PHPDoc annotations. This is especially critical for:
* Eloquent Models & Collections: Use generics for relationships and collections.
* For relationships: \Illuminate\Database\Eloquent\Relations\HasMany<RelatedModel, $this>
* For collections: \Illuminate\Database\Eloquent\Collection<int, ModelName>
* Basic Arrays: Use the array<key_type, value_type> syntax.
* For a simple list of strings: array<string> or array<int, string>
* For an associative array with string keys: array<string, mixed> or array<string, string>
* Complex Arrays & Shapes (Critical): Define the exact structure of complex arrays using shapes. This is essential for type safety.
* For an associative array where each value is another structured array: array<string, array{original_url: string, filename: string, key: string}>
* For a similar structure with fewer keys: array<string, array{filename: string, key: string}>
* Method Parameters & Returns: Be explicit.
* If a parameter can be a single item or an array of items: SomeClass|array<int, SomeClass>
* If a method can return a value or null: ?string or string|null
Example Scenarios (Based on project conventions):
* Scenario 1: A method accepts a string or an array of strings.
* Your annotation: @param string|array<string> $key
* Scenario 2: A method returns an associative array of model properties.
* Your annotation: @return array<string, mixed>
* Scenario 3: An Eloquent model property is a JSON-casted array of strings.
* Your annotation: @property array<string>|null $apc_badges
* Scenario 4: An Eloquent `HasMany` relationship.
* Your annotation: @return \Illuminate\Database\Eloquent\Relations\HasMany<App\Models\ListingData, $this>
* Scenario 5 (Advanced): A parameter is an associative array mapping a string to a specific data structure (an array shape).
* Your annotation: @param array<string, array{original_url: string, filename: string, key: string}> $imageUrls
* Scenario 6 (Advanced): A method returns a complex array shape.
* Your annotation: @return array<string, array{original_url: string, filename: string, key: string}>
When you provide the corrected code, do not add any explanations unless specifically asked. Just return the fixed code block.
Your Job is done when PHPstan Shows: [OK] No errors
in CLAUDE.md i have this, and maybe that´s the part which makes it hard for the LLM to choose between using the agent or not, i don´t know 🤷
• Code quality checks:
- Run PHPStan for type checking: docker exec -w /app container-name php vendor/bin/phpstan analyse <files> --memory-limit=256M
btw i am using KIMI K2 via groq here.... but i have noticed the exact same problem with claude code.... there i also have to mention explicit to use the sub-agent "phpstan-fixer"...... i am using the same CLAUDE.md and the same agent file... so i guess this whole
thing is more an issue based on wrong prompting ? 😏
I am experiencing the exact same. I have defined multiple agents and the system works to create if in AGENT.md i explicitly tell again which agents to use. Thing is i basically only replicated the description of the agent.
Same issue for me. I see my agent as expected (without having to mention it) running when I'm inside OpenCode, but running "opencode run " I have to explicitly ask for the agent.
Just to add to this - I stumbled upon this repo of agents on twitter and tried to add them to opencode. It did work but it's not very intuitive.
The agent docs mention - "Agents are automatically available through the Task tool when configured." but I'm not entirely sure what the Task tool is (might be something obvious, sorry if so). There is almost no mention of it in the docs also (that I can find).
Moreover, mentioning the agent (@some-agent-name) shows no hint, but it does work.
I would love to contribute to the docs at least, just not sure how it works.
description: Use this agent PROACTIVELY for fixing PHPStan errors.
You can also add some examples:
description: >- Use this agent PROACTIVELY for fixing PHPStan errors. Examples: <example> Context: User wants to check the project for type checking user: "Run PHPStan for type checking the project" assistant: "I'll use the phpstan-error-fixer agent to type check the project" </example>
Hopefully with this you don't need to mention the name. You can just say: "Is there any type checking issues in the blah directory?". And it should understand the context and delegate to the agent.
personally, i am okay (now) with explicitly mentioning an agent or switching between them. @thdxr feel free to close the issue if nothing is open here. thanks.
Activity
thdxr commentedon Jul 25, 2025
hmm thats pretty annoying - i'll need to do some experimenting to see if we can get this to behave better
thdxr commentedon Jul 25, 2025
can you actually share your full agent? i'll try it
michabbb commentedon Jul 25, 2025
sure... here´s what i tried so far 😏
in
CLAUDE.mdi have this, and maybe that´s the part which makes it hard for the LLM to choose between using the agent or not, i don´t know 🤷btw i am using KIMI K2 via groq here.... but i have noticed the exact same problem with claude code.... there i also have to mention explicit to use the sub-agent "phpstan-fixer"...... i am using the same CLAUDE.md and the same agent file... so i guess this whole
thing is more an issue based on wrong prompting ? 😏
JUVOJustin commentedon Jul 25, 2025
I am experiencing the exact same. I have defined multiple agents and the system works to create if in AGENT.md i explicitly tell again which agents to use. Thing is i basically only replicated the description of the agent.
FringeDweller commentedon Jul 31, 2025
I'm having exactly the same issue. Many agents tested, using md files.
zmasinelli commentedon Aug 2, 2025
Same issue for me. I see my agent as expected (without having to mention it) running when I'm inside OpenCode, but running "opencode run " I have to explicitly ask for the agent.
todor-a commentedon Aug 5, 2025
Just to add to this - I stumbled upon this repo of agents on twitter and tried to add them to opencode. It did work but it's not very intuitive.
The agent docs mention - "Agents are automatically available through the Task tool when configured." but I'm not entirely sure what the Task tool is (might be something obvious, sorry if so). There is almost no mention of it in the docs also (that I can find).
Moreover, mentioning the agent (
@some-agent-name) shows no hint, but it does work.I would love to contribute to the docs at least, just not sure how it works.
michabbb commentedon Aug 7, 2025
at the moment, i am handling agents like a stupid alexa 😏 always make sure the "intention" is crystal clear:
"use the task tool to call the agent [......] for/to [......]"
something like that always works. using "mentioning" with a visual indicator (like claude code) would be better of course.... 😏
arsham commentedon Sep 11, 2025
Try this description:
You can also add some examples:
Hopefully with this you don't need to mention the name. You can just say: "Is there any type checking issues in the blah directory?". And it should understand the context and delegate to the agent.
michabbb commentedon Sep 11, 2025
personally, i am okay (now) with explicitly mentioning an agent or switching between them. @thdxr feel free to close the issue if nothing is open here. thanks.