Imported from aidenrigali04-ops/Vantera (
AGENTS.md). Install upstream withnpx skills add aidenrigali04-ops/Vantera. Copyright stays with the author.
AGENTS.md
This file provides guidance to AI coding agents when working on HubSpot components
IMPORTANT: IF THE 'HubSpot' MCP SERVER IS INSTALLED USE THE TOOLS BEFORE TRYING TO MANUALLY USE CLI COMMANDS OR BEFORE TRYING TO DO ANYTHING WITH HUBSPOT ASSETS
HubSpot Project Information
- The project configuration is in the
hsproject.jsonfile - A directory is considered a part of the project if it or a directory above it contains a
hsproject.jsonfile - The project src directory is defined in the
srcDirfield in thehsproject.json - The project's platform version is defined in
platformVersionin thehsproject.json - The
platformVersiondetermines what features the project has access to as well as the shape of the configuration files
npm packages
@hubspot/ui-extensions
- In the
@hubspot/ui-extensionsnpm package, only the component properties defined by the component are valid.styleproperties are not valid
Component Information
General
- Component configuration files must end with
-hsmeta.json - The
uidfield in the-hsmeta.jsonfiles must be unique with the project - The
typefield in the-hsmeta.jsonfiles defines the type of the component - Components can not be in nested subdirectories, only the specified directories in their corresponding component rules.
- Example components can be found in https://github.com/HubSpot/hubspot-project-components. The directories are split up by platform version and follow this format
${platformVersion}/components - All component subdirectories must be in the project source directory
app component
- There can only be one
appcomponent appcomponent must be in theappdirectory- If the
config.distributionfield is set tomarketplace, the only validconfig.auth.typevalue isoauth
card
cardcomponents must be in theapp/cardsdirectory- The global
windowobject is not available in thecardcomponent - Cannot use
window.fetch, and instead must use thehubspot.fetchfunction provided by the@hubspot/ui-extensionsnpm package. Any urls called with thehubspot.fetchfunction must be added to theconfig.permittedUrls.fetcharray in theappcomponent's hsmeta.json file - Only components exported from the
@hubspot/ui-extensionsnpm package can be used incardcomponents
Available Hooks for Card Components
Prefer hooks over hubspot.fetch — use hooks to access CRM data and extension context before falling back to hubspot.fetch for external HTTP requests. Hooks must be called at the component level, not inside conditionals or loops. The list below may not be exhaustive — refer to the hooks documentation as the source of truth for all available hooks and their parameters.
Universal hooks (available across all extension points):
useExtensionApi- Access both context and actions from a single hookuseExtensionContext- Access contextual information about the extension environment (portal, user, extension metadata)useExtensionActions- Access all available actions for the current extension pointuseCrmSearch- Search CRM recordsuseDebounce- Debounce a rapidly-changing value
CRM-specific hooks (available in crm.record.tab, crm.record.sidebar, crm.preview, helpdesk.sidebar extension points):
useCrmProperties- Fetch properties from the current CRM recorduseAssociations- Fetch associated CRM records
Available Actions for Card Components
Access actions via the useExtensionActions hook or the actions parameter from hubspot.extend(). The list below may not be exhaustive — refer to the actions documentation as the source of truth for all available actions and their parameters.
Universal actions (available across all extension points):
addAlert- Display an alert bannerreloadPage- Reload the current pagecopyTextToClipboard- Copy text to clipboard; requires explicit user interactioncloseOverlay- Close an open overlay or modal by its idopenIframeModal- Open a URL in an iframe modal
CRM-specific actions (available in crm.record.tab, crm.record.sidebar, crm.preview, helpdesk.sidebar extension points):
fetchCrmObjectProperties- Fetch property values from the current CRM recordrefreshObjectProperties- Refresh CRM record properties in the UI without a full page reloadonCrmPropertiesUpdate- Subscribe to UI-level changes to CRM properties
Context Object
Access context via the useExtensionContext hook or the context parameter from hubspot.extend(). The list below may not be exhaustive — refer to the context documentation as the source of truth for all available context fields.
Universal fields (available on all extension points):
location- Extension point identifierportal.id/portal.timezone/portal.dataHostingLocation- Account infouser.id/user.email/user.firstName/user.lastName/user.locale/user.language/user.teams/user.permissions- User infovariables- Project configuration variables
CRM-specific fields (available in crm.record.tab, crm.record.sidebar, crm.preview, helpdesk.sidebar extension points):
crm.objectId- Current CRM record's IDcrm.objectTypeId- Record type IDextension.appId/extension.appName/extension.cardTitle- Extension metadata
Logging
Use the logger API to send custom log messages. In local development mode, logs go to the browser console only; in production they are sent to HubSpot and viewable via hs project logs. The list below may not be exhaustive — refer to the logging documentation as the source of truth for all available logging methods.
logger.info- Informational messageslogger.debug- Debug messageslogger.warn- Warning messageslogger.error- Error messages
app-event
app-eventcomponents must be in theapp/app-eventsdirectory
app-object
app-objectcomponents must be in theapp/app-objectdirectory
app-function
app-functioncomponents must be in theapp/functionsdirectoryapp-functioncomponents are not available whenconfig.distributionis set tomarketplacein theappcomponent-hsmeta.jsonfile
settings
- There can only be one
settingscomponent settingscomponents must be in theapp/settingsdirectory- The global
windowobject is not available in thesettingscomponent - Cannot use
window.fetch, and instead must use thehubspot.fetchfunction provided by the@hubspot/ui-extensionsnpm package. Any urls called with thehubspot.fetchfunction must be added to theconfig.permittedUrls.fetcharray in theappcomponent's hsmeta.json file - Only components exported from the
@hubspot/ui-extensionsnpm package can be used insettingscomponents - React Components from
@hubspot/ui-extensions/crmcannot be used insettingscomponents
scim
- There can only be one
scimcomponent scimcomponents must be in theapp/scimdirectory
webhooks
- There can only be one
webhookscomponent. webhookscomponents must be in theapp/webhooksdirectorywebhookscomponents can only be in projects whereconfig.distributionis private andconfig.auth.typeisstatic
workflow-actions
workflow-actioncomponents must be in theapp/workflow-actionsdirectory
HubSpot CLI commands
- All the commands and subcommands have a
--helpargument that provides details on the command and it's arguments - The help output is standard yargs output
- The commands for working with projects in HubSpot are subcommands of
hs project - Debugging flag that can be added to
hscommands and subcommands:--debug - Debugging problems with CLI installation:
hs doctor hs project openwill open the current project page in the browserhs initis required to set up the hubspot configuration filehs authwill authenticate a new account. This will require a user to open a browser and paste a token in a CLI prompt.- All the commands for managing HubSpot accounts in the CLI are subcommands of
hs account
General
- Follow existing patterns in the codebase
- Use proper component structure based on component
typein the-hsmeta.jsonfile - Ensure configuration files follow HubSpot naming conventions
- Always validate that components are placed in correct directories