Introduction
This guide provides a comprehensive set of advanced prompts for interacting with the Claude Code CLI, tailored for FiveM development with QB-core. By following these examples, you can leverage the power of Claude directly from your command line to plan, create, debug, and optimize your FiveM server.
Planning & Script Creation
Planning a New Script
Before writing any code, it's crucial to have a solid plan. You can use Claude to help you outline the structure and functionality of a new script.
Prompt:
<?xml version="1.0" encoding="UTF-8"?>
<prompt>
<instruction>
I need to create a new script for my QB-core server that allows players to purchase and manage their own player-owned houses. Please help me plan the script by outlining the main features, the required database tables, and the file structure.
</instruction>
</prompt>
Creating a Script from a Plan
Once you have a plan, you can ask Claude to generate the code for you. Be sure to provide the plan in the prompt.
Prompt:
<?xml version="1.0" encoding="UTF-8"?>
<prompt>
<instruction>
Please create a new FiveM script for QB-core based on the following plan.
</instruction>
<context>
<plan>
Features:
- Players can purchase houses from a real estate agent.
- Players can furnish their houses with a variety of furniture items.
- Players can store items and vehicles in their houses.
- Players can lock and unlock their houses.
Database Tables:
- `player_houses` (id, citizenid, house_id, purchased_date)
- `house_furniture` (id, house_id, furniture_id, position, rotation)
File Structure:
- `client/main.lua`
- `server/main.lua`
- `shared/config.lua`
- `ui/index.html`
- `ui/css/styles.css`
- `ui/js/main.js`
</plan>
</context>
</prompt>
Systems & Features
Creating a Custom Inventory System
You can use Claude to help you create complex systems like a custom inventory.
Prompt:
<?xml version="1.0" encoding="UTF-8"?>
<prompt>
<instruction>
I need to create a custom inventory system for my QB-core server. The inventory should be displayed in a NUI and should support drag-and-drop functionality. Please provide the code for the NUI and the client and server-side logic to handle item management.
</instruction>
</prompt>
Debugging
Debugging a Script Error
When you encounter an error, you can ask Claude to help you debug it. Be sure to provide the error message and the relevant code.
Prompt:
<?xml version="1.0" encoding="UTF-8"?>
<prompt>
<instruction>
I am getting the following error in my FiveM server console. Please help me debug it.
</instruction>
<context>
<error_message>
[script:my-script] error during NuiMessageCallback: citizenid is nil
</error_message>
<code file_path="client/main.lua">
RegisterNUICallback('getItemAmount', function(data, cb)
local PlayerData = QBCore.Functions.GetPlayerData()
local amount = PlayerData.items[data.item].amount
cb(amount)
end)
</code>
</context>
</prompt>
Optimizing a Script for Performance
If you have a script that is causing performance issues, you can ask Claude to help you optimize it.
Prompt:
<?xml version="1.0" encoding="UTF-8"?>
<prompt>
<instruction>
I have a script that is causing performance issues on my server. It loops through all players every frame to check their distance to a specific location. Please help me optimize this script for better performance.
</instruction>
<context>
<code file_path="client/main.lua">
Citizen.CreateThread(function()
while true do
Citizen.Wait(0)
local playerPed = PlayerPedId()
local playerCoords = GetEntityCoords(playerPed)
local distance = #(playerCoords - vector3(100.0, 100.0, 100.0))
if distance < 10.0 then
-- Do something
end
end
end)
</code>
</context>
</prompt>
Implementing Server-Side Caching
You can use Claude to help you implement caching to improve server performance.
Prompt:
<?xml version="1.0" encoding="UTF-8"?>
<prompt>
<instruction>
I want to implement server-side caching for my QB-core server to reduce the number of database queries. Please provide an example of how I can cache player data on the server and retrieve it when needed.
</instruction>
</prompt>
Using the Claude Code CLI in a Shell Script
You can use the Claude Code CLI in a shell script to automate tasks. For example, you could create a script that generates a new FiveM resource from a template.
Example Script:
#!/bin/bash
# This script generates a new FiveM resource from a template.
# Get the name of the resource from the user.
read -p "Enter the name of the resource: " resource_name
# Create the resource directory.
mkdir $resource_name
# Create the resource files.
touch $resource_name/client.lua
touch $resource_name/server.lua
touch $resource_name/shared.lua
# Generate the resource manifest.
claude-code-cli generate manifest --name $resource_name > $resource_name/fxmanifest.lua