Skip to content

Runs daily Claude Code usage analytics

<command_structure>
  <metadata>
    <instruction>You must complete all three stages in order and cannot skip any stage or the completion indicator.</instruction>
  </metadata>

  <preparation_stage>
    <description>Before you begin any work, you must validate that you have sufficient context and resources</description>
    <requirements>
      <requirement_list>
        <requirement>Node.js and npm are installed and accessible</requirement>
        <requirement>Network access for downloading ccusage package</requirement>
        <requirement>Terminal/command line access for running npm commands</requirement>
        <requirement>Permissions to execute npm and node commands</requirement>
      </requirement_list>
    </requirements>
    <critical_validation>
      <condition>If ANY requirement fails, immediately stop and respond with:</condition>
      <error_response>ERROR: Insufficient context - missing [specific requirement]. Please ensure Node.js/npm are installed and network access is available.</error_response>
      <instruction>Do not proceed to execution. Only continue if you can confirm you have everything needed.</instruction>
    </critical_validation>
  </preparation_stage>

  <execution_stage>
    <success_criteria>Successfully execute ccusage daily command and display usage analytics results</success_criteria>
    <error_handling>
      <policy>IF any step fails:</policy>
      <steps>
        <step>Log error with specific command execution component that failed</step>
        <step>Attempt retry once with alternative npm execution approach</step>
        <step>If still failing, provide manual installation instructions and mark as INCOMPLETE</step>
      </steps>
    </error_handling>
    <execution_steps>
      <instruction>Execute these steps in exact order:</instruction>
      <step_list>
        <step>Execute npx ccusage@latest daily command via bash tool</step>
        <step>Capture and display usage analytics output</step>
        <step>Validate that command executed successfully and data was retrieved</step>
      </step_list>
    </execution_steps>
  </execution_stage>

  <resolution_stage>
    <description>Analyze the complete execution:</description>
    <validation_areas>
      <area>Verify ccusage command executed without errors</area>
      <area>Confirm usage analytics data was successfully retrieved and displayed</area>
      <area>Check that daily usage information is current and relevant</area>
    </validation_areas>
    <completion_indicator>
      <format>Always end with:</format>
      <template>
        FLOW COMPLETE:  execution finished - Status: [SUCCESS/PARTIAL/FAILED] - Timestamp: [completion time]
        [Summary of execution and outcomes]
      </template>
    </completion_indicator>
  </resolution_stage>
</command_structure>