Many developers are using AI tools to do development, especially those integrated into their IDEs. Cursor, Cline, Windsurf, etc., to name a few agentic solution.
As the models have gotten smarter, they getting much better at writing code, however, they are not built upon magic. The agents are always thirsty for context and if not provided by the user/agent, the models rely on their training data which is often incorrect or dated.
When building addons for XF, I have had to use a few techniques, but one major improvement that I have done is to create Xenforo specific rules and guides that the agent can use to make decisions. For example, when you ask Cline to build you a CLI command for XF, out of the box it does very poorly and produces something full of errors if it even works at all, irregardless of the model. However, when I provide it these markdown instructions as part of a library of them, it creates the commands flawlessly each time:
As I develop, I refine these rules myself or even have the agent recommend new content within the rules that would have helped them solve a particular XF related problem we were having developing.
I am not alone in doing this. Most of these agents have these abilities. Cline/Cursor/Windsurf for example, all allow nested instructions within a project.
I myself made many of these rules as a part of an internal library in our company so people can just install them via NPM and select which rules they want in their projects.
If anything like this is going on internally here in Xenforo, it would be really awesome if you could share a list of rules or guidelines for developers to be able to drop into their IDEs. It certainly speeds up development and will allow more addons to be released faster. Just a thought to consider.
As the models have gotten smarter, they getting much better at writing code, however, they are not built upon magic. The agents are always thirsty for context and if not provided by the user/agent, the models rely on their training data which is often incorrect or dated.
When building addons for XF, I have had to use a few techniques, but one major improvement that I have done is to create Xenforo specific rules and guides that the agent can use to make decisions. For example, when you ask Cline to build you a CLI command for XF, out of the box it does very poorly and produces something full of errors if it even works at all, irregardless of the model. However, when I provide it these markdown instructions as part of a library of them, it creates the commands flawlessly each time:
# XenForo Addon Development - CLI Commands Guidelines
## Creating CLI Commands
XenForo provides a command line interface (CLI) based on Symfony Console. CLI commands can be useful for:
## File Structure
- Running maintenance tasks
- Performing bulk operations
- Executing scheduled jobs
- Testing and debugging
When creating CLI command files:
1. Place files in the appropriate directory:src/addons/YourNamespace/YourAddon/Cli/Command/
2. Follow proper namespacing patterns:YourNamespace\YourAddon\Cli\Command
3. Extend the Symfony Console Command class
4. Provide complete and working code in the files
5. Include thorough documentation in the code
## Example CLI Command File
## Command ConfigurationPHP:<?php namespace Test\Test\Cli\Command; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Helper\ProgressBar; use XF; class Test extends Command { protected function configure() { $this->setName('tst:test')->setDescription('Does a test'); } protected function execute(InputInterface $input, OutputInterface $output) { $output->writeln('This is a test'); } }
In theconfigure()
method:
1. Set the command name usingsetName()
- follow the naming convention:vendorprefix:commandname
2. Set a description usingsetDescription()
3. Optionally add arguments and options:
## Command ExecutionCode:php $this->addArgument('argument-name', InputArgument::REQUIRED, 'Description of argument'); $this->addOption('option-name', 'o', InputOption::VALUE_OPTIONAL, 'Description of option', 'default-value');
1. Implement theexecute()
method which receives:
-$input
- for accessing arguments and options
-$output
- for writing messages to the console
2. Return an integer status code:
-Command::SUCCESS
(or 0) - success
-Command::FAILURE
(or 1) - error
-Command::INVALID
(or 2) - invalid input
## Running CLI Commands
Execute commands from the XenForo root directory:
Example:Code:php cmd.php your-prefix:command-name [arguments] [--options]
## Advanced FeaturesCode:php cmd.php tst:test
### Working with Input
### Output FormattingPHP:// Get arguments $argumentValue = $input->getArgument('argument-name'); // Get options $optionValue = $input->getOption('option-name');
### Progress BarsPHP:// Standard output $output->writeln('Normal message'); // Formatted output $output->writeln('<info>Success message</info>'); $output->writeln('<comment>Comment message</comment>'); $output->writeln('<error>Error message</error>');
## Best PracticesPHP:$count = 100; $progressBar = new ProgressBar($output, $count); $progressBar->start(); for ($i = 0; $i < $count; $i++) { // Do work... $progressBar->advance(); } $progressBar->finish(); $output->writeln('');
1. Use meaningful command names that reflect their purpose
2. Provide clear descriptions for commands, arguments, and options
3. Include proper error handling
4. Add confirmation for destructive operations
5. Output appropriate information about progress and results
6. Document commands thoroughly in your add-on's documentation
As I develop, I refine these rules myself or even have the agent recommend new content within the rules that would have helped them solve a particular XF related problem we were having developing.
I am not alone in doing this. Most of these agents have these abilities. Cline/Cursor/Windsurf for example, all allow nested instructions within a project.
I myself made many of these rules as a part of an internal library in our company so people can just install them via NPM and select which rules they want in their projects.
If anything like this is going on internally here in Xenforo, it would be really awesome if you could share a list of rules or guidelines for developers to be able to drop into their IDEs. It certainly speeds up development and will allow more addons to be released faster. Just a thought to consider.