Skip to content

Commit 716bba1

Browse files
committed
Enrich command and flag descriptions for AI agent consumption
Merge the detailed flag descriptions from PR #15 (max lengths, type format hints, behavioral details, category explanations) with the examples and Long descriptions from the search_by_contract work. Every Short, Long, and flag help string is now maximally descriptive so AI agents can select the right commands and flags without ambiguity.
1 parent 3dee67a commit 716bba1

11 files changed

Lines changed: 141 additions & 83 deletions

File tree

cli/root.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,18 @@ var apiKeyFlag string
2424

2525
var rootCmd = &cobra.Command{
2626
Use: "dune",
27-
Short: "Dune CLI — interact with the Dune Analytics API",
28-
Long: "A command-line interface for interacting with the Dune Analytics API.\n" +
29-
"Manage queries, execute DuneSQL queries, search datasets, browse documentation, and monitor usage.",
27+
Short: "Dune CLI — query, explore, and manage blockchain data on Dune Analytics",
28+
Long: "A command-line interface for the Dune Analytics platform.\n\n" +
29+
"Discover datasets across the Dune catalog, execute SQL queries (DuneSQL dialect),\n" +
30+
"retrieve execution results, and manage your saved queries — all from the terminal.\n\n" +
31+
"Capabilities:\n" +
32+
" - Search datasets by keyword, contract address, category, or blockchain\n" +
33+
" - Create, update, archive, and retrieve saved DuneSQL queries\n" +
34+
" - Execute saved queries or raw DuneSQL and display results\n" +
35+
" - Browse Dune documentation for DuneSQL syntax, API references, and guides\n" +
36+
" - Monitor credit usage, storage consumption, and billing periods\n\n" +
37+
"Authenticate with an API key via --api-key, the DUNE_API_KEY environment variable,\n" +
38+
"or by running `dune auth`.",
3039
PersistentPreRunE: func(cmd *cobra.Command, _ []string) error {
3140
if cmd.Annotations["skipAuth"] == "true" {
3241
return nil

cmd/dataset/search.go

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,31 +13,37 @@ import (
1313
func newSearchCmd() *cobra.Command {
1414
cmd := &cobra.Command{
1515
Use: "search",
16-
Short: "Search for datasets across the Dune catalog",
17-
Long: "Search for datasets across the Dune catalog by keyword, category, blockchain, and more.\n\n" +
18-
"The catalog includes canonical blockchain data, decoded contract tables,\n" +
19-
"Spellbook transformations, and community datasets. Use --include-schema\n" +
20-
"to get column names and types for SQL generation.\n\n" +
16+
Short: "Search for tables and datasets across the Dune catalog",
17+
Long: "Natural-language table discovery across the Dune catalog. Use this command\n" +
18+
"to find concrete table names for use in SQL queries.\n\n" +
19+
"The catalog includes:\n" +
20+
" - canonical: chain-native primitives (blocks, transactions, logs, traces)\n" +
21+
" - decoded: ABI-level events and function calls parsed from contract interactions\n" +
22+
" - spell: curated Spellbook transformation datasets (e.g. dex.trades)\n" +
23+
" - community: user-contributed tables and uploads\n\n" +
24+
"Filter by category, blockchain, schema, dataset type, or ownership scope.\n" +
25+
"Use --include-schema to get column names and types for SQL generation.\n\n" +
26+
"For contract-specific lookup, use 'dune dataset search-by-contract' instead.\n\n" +
2127
"Examples:\n" +
2228
" dune dataset search --query \"uniswap swaps\"\n" +
2329
" dune dataset search --query \"transfers\" --categories decoded --blockchains ethereum\n" +
2430
" dune dataset search --query \"dex trades\" --categories spell --include-schema --output json\n" +
25-
" dune dataset search --owner-scope me",
31+
" dune dataset search --query \"*\" --owner-scope me",
2632
RunE: runSearch,
2733
}
2834

29-
cmd.Flags().String("query", "", "search query text")
30-
cmd.Flags().StringArray("categories", nil, "filter by category (canonical, decoded, spell, community)")
31-
cmd.Flags().StringArray("blockchains", nil, "filter by blockchain")
35+
cmd.Flags().String("query", "", "natural-language search intent or entity hints (e.g. 'uniswap v3 swaps'); use '*' to browse without keyword bias")
36+
cmd.Flags().StringArray("categories", nil, "filter by table family: canonical (chain primitives), decoded (ABI-level events/calls), spell (curated datasets), community (user-contributed)")
37+
cmd.Flags().StringArray("blockchains", nil, "chain scope to reduce ambiguity and improve ranking (e.g. ethereum, solana, arbitrum)")
3238
cmd.Flags().StringArray("dataset-types", nil,
33-
"filter by dataset type (dune_table, decoded_table, spell, uploaded_table, transformation_table, transformation_view)")
34-
cmd.Flags().StringArray("schemas", nil, "filter by schema")
35-
cmd.Flags().String("owner-scope", "", "ownership filter (all, me, team)")
36-
cmd.Flags().Bool("include-private", false, "include private datasets")
37-
cmd.Flags().Bool("include-schema", false, "include column schema in results")
38-
cmd.Flags().Bool("include-metadata", false, "include metadata in results")
39-
cmd.Flags().Int32("limit", 20, "maximum number of results")
40-
cmd.Flags().Int32("offset", 0, "pagination offset")
39+
"fine-grained dataset type filter: dune_table, decoded_table, spell, uploaded_table, transformation_table, transformation_view")
40+
cmd.Flags().StringArray("schemas", nil, "schema/namespace constraint for high precision (e.g. dex, uniswap_v3_ethereum)")
41+
cmd.Flags().String("owner-scope", "", "ownership filter: all (default), me, or team; does NOT automatically include private datasets")
42+
cmd.Flags().Bool("include-private", false, "widen results to include private datasets visible to the authenticated user/team alongside public ones")
43+
cmd.Flags().Bool("include-schema", false, "include column-level schema (name, type, nullable) for every result; useful when preparing SQL")
44+
cmd.Flags().Bool("include-metadata", false, "include category-specific metadata (page_rank_score, description, abi_type, contract_name, project_name, etc.)")
45+
cmd.Flags().Int32("limit", 20, "number of results per page; use 5-15 for quick checks, 20-50 for deeper exploration")
46+
cmd.Flags().Int32("offset", 0, "pagination offset; combine with limit to page through large result sets")
4147
output.AddFormatFlag(cmd, "text")
4248

4349
return cmd

cmd/docs/search.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,15 @@ const defaultMCPEndpoint = "https://docs.dune.com/mcp"
1414
func newSearchCmd() *cobra.Command {
1515
cmd := &cobra.Command{
1616
Use: "search",
17-
Short: "Search the Dune documentation",
18-
Long: "Search the official Dune documentation. No authentication required.\n\n" +
19-
"Look up DuneSQL syntax, API references, table naming conventions,\n" +
20-
"and Dune platform concepts.\n\n" +
17+
Short: "Search the Dune documentation for guides, API references, and code examples",
18+
Long: "Search across all Dune documentation pages including guides, API references,\n" +
19+
"DuneSQL syntax, table naming conventions, and code examples.\n" +
20+
"Does not require authentication.\n\n" +
21+
"Useful for looking up:\n" +
22+
" - DuneSQL functions and syntax (date/time, string, aggregate, window functions)\n" +
23+
" - API endpoint references and authentication\n" +
24+
" - Table naming conventions and dataset structure\n" +
25+
" - Dune platform concepts (decoding, Spellbook, materialized views)\n\n" +
2126
"Examples:\n" +
2227
" dune docs search --query \"DuneSQL string functions\"\n" +
2328
" dune docs search --query \"execute query API\" --api-reference-only\n" +
@@ -26,7 +31,7 @@ func newSearchCmd() *cobra.Command {
2631
RunE: runSearch,
2732
}
2833

29-
cmd.Flags().String("query", "", "search query text, e.g. 'DuneSQL date functions' or 'API authentication' (required)")
34+
cmd.Flags().String("query", "", "natural-language search query for Dune docs; e.g. 'DuneSQL date functions', 'API authentication', 'decoded tables meaning', 'query pagination' (required)")
3035
_ = cmd.MarkFlagRequired("query")
3136
cmd.Flags().Bool("api-reference-only", false, "prioritize API reference pages over conceptual guides")
3237
cmd.Flags().Bool("code-only", false, "prioritize pages with executable examples and code snippets")

cmd/execution/execution.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ func NewExecutionCmd() *cobra.Command {
77
cmd := &cobra.Command{
88
Use: "execution",
99
Short: "Retrieve and inspect query execution results",
10+
Long: "Retrieve and inspect the results of query executions.\n\n" +
11+
"Use 'execution results <execution-id>' to fetch results from a previously\n" +
12+
"submitted query execution. The execution ID is returned when running queries\n" +
13+
"with 'dune query run --no-wait' or 'dune query run-sql --no-wait'.",
1014
}
1115
cmd.AddCommand(newResultsCmd())
1216
return cmd

cmd/execution/results.go

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,27 +17,31 @@ var PollInterval = 2 * time.Second
1717
func newResultsCmd() *cobra.Command {
1818
cmd := &cobra.Command{
1919
Use: "results <execution-id>",
20-
Short: "Fetch results of a query execution",
21-
Long: "Fetch results of a query execution by its execution ID.\n\n" +
22-
"Use this after submitting a query with --no-wait, or to re-fetch results from\n" +
23-
"a completed execution. The command handles all execution states:\n" +
24-
" - Completed: displays result rows\n" +
25-
" - Pending/Executing: shows current state (re-run later)\n" +
26-
" - Failed: returns the error message\n" +
27-
" - Cancelled: returns cancellation notice\n\n" +
20+
Short: "Retrieve execution results for a query execution by execution ID",
21+
Long: "Retrieve the results of a query execution. By default, waits for the execution\n" +
22+
"to complete (up to the timeout) before returning results.\n\n" +
23+
"Behavior:\n" +
24+
" 1. Checks the current execution status\n" +
25+
" 2. If still running: polls every 2 seconds until complete or timeout is reached\n" +
26+
" 3. If completed: returns the result data\n" +
27+
" 4. If failed/cancelled: returns the error details\n\n" +
28+
"Use --no-wait to return the current state immediately without polling.\n" +
2829
"Use --limit and --offset to paginate through large result sets.\n\n" +
30+
"Use this after submitting a query with --no-wait, or to re-fetch results from\n" +
31+
"a completed execution.\n\n" +
2932
"Examples:\n" +
3033
" dune execution results 01JXYZ...\n" +
3134
" dune execution results 01JXYZ... --limit 100 --offset 200\n" +
35+
" dune execution results 01JXYZ... --no-wait\n" +
3236
" dune execution results 01JXYZ... --output json",
3337
Args: cobra.ExactArgs(1),
3438
RunE: runResults,
3539
}
3640

37-
cmd.Flags().Int("limit", 0, "maximum number of result rows to return (0 = all)")
38-
cmd.Flags().Int("offset", 0, "number of rows to skip before returning results, used for pagination")
39-
cmd.Flags().Bool("no-wait", false, "return the current execution state immediately without waiting for completion")
40-
cmd.Flags().Int("timeout", 300, "maximum seconds to wait for the execution to complete before timing out")
41+
cmd.Flags().Int("limit", 0, "maximum number of result rows to return (0 = all); use with --offset to paginate large result sets")
42+
cmd.Flags().Int("offset", 0, "number of rows to skip before starting to return results; use with --limit for pagination through large result sets")
43+
cmd.Flags().Bool("no-wait", false, "return the current execution state immediately without waiting for completion; useful for checking status of long-running queries")
44+
cmd.Flags().Int("timeout", 300, "maximum seconds to wait for the execution to complete before timing out (default 300s = 5 minutes)")
4145
output.AddFormatFlag(cmd, "text")
4246

4347
return cmd

cmd/query/create.go

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,26 @@ import (
1212
func newCreateCmd() *cobra.Command {
1313
cmd := &cobra.Command{
1414
Use: "create",
15-
Short: "Create a new saved query",
16-
Long: "Create a new saved DuneSQL query. Returns the numeric query ID on success.\n" +
17-
"Use --temp to create a temporary query that won't appear in your saved queries list.\n\n" +
15+
Short: "Create a new saved Dune query and return the query ID",
16+
Long: "Create a new SQL query on Dune. Returns the query ID on success.\n\n" +
17+
"The query is written in DuneSQL dialect. If the query targets tables with\n" +
18+
"known partition columns, include a WHERE filter on those columns\n" +
19+
"(e.g. WHERE block_date >= CURRENT_DATE - INTERVAL '7' DAY) to enable\n" +
20+
"partition pruning and reduce query cost.\n\n" +
21+
"Use --temp to create a temporary query that won't appear in the dune.com\n" +
22+
"library or be accessible when shared. Temporary queries are auto-deleted.\n\n" +
1823
"Examples:\n" +
1924
" dune query create --name \"Recent Blocks\" --sql \"SELECT * FROM ethereum.blocks LIMIT 10\"\n" +
2025
" dune query create --name \"My Query\" --sql \"SELECT 1\" --private --description \"Test query\"\n" +
2126
" dune query create --name \"Throwaway\" --sql \"SELECT 1\" --temp",
2227
RunE: runCreate,
2328
}
2429

25-
cmd.Flags().String("name", "", "query name (required)")
26-
cmd.Flags().String("sql", "", "DuneSQL query text (required)")
27-
cmd.Flags().String("description", "", "query description")
28-
cmd.Flags().Bool("private", false, "make the query private")
29-
cmd.Flags().Bool("temp", false, "create a temporary query (auto-deleted, not shown in your saved queries)")
30+
cmd.Flags().String("name", "", "human-readable query title, max 600 characters (required)")
31+
cmd.Flags().String("sql", "", "the SQL query text in DuneSQL dialect, max 500,000 characters (required)")
32+
cmd.Flags().String("description", "", "short description of what the query does, max 1,000 characters")
33+
cmd.Flags().Bool("private", false, "make the query private; may be forced by team privacy settings")
34+
cmd.Flags().Bool("temp", false, "create a temporary query that won't appear in the dune.com library or be accessible when shared; auto-deleted")
3035
_ = cmd.MarkFlagRequired("name")
3136
_ = cmd.MarkFlagRequired("sql")
3237
output.AddFormatFlag(cmd, "text")

cmd/query/query.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,15 @@ import "github.com/spf13/cobra"
66
func NewQueryCmd() *cobra.Command {
77
cmd := &cobra.Command{
88
Use: "query",
9-
Short: "Manage Dune queries",
9+
Short: "Create, retrieve, update, execute, and archive Dune queries",
1010
Long: "Create, retrieve, update, archive, and execute DuneSQL queries.\n\n" +
11-
"Use 'query create' to save a reusable query, 'query run' to execute a saved query,\n" +
12-
"or 'query run-sql' to execute raw DuneSQL without saving.",
11+
"Subcommands:\n" +
12+
" create - Save a new reusable DuneSQL query and get its query ID\n" +
13+
" get - Fetch a saved query's SQL, metadata, and execution state\n" +
14+
" update - Modify a query's SQL, title, description, privacy, or tags\n" +
15+
" archive - Hide a query from the library (still retrievable by ID)\n" +
16+
" run - Execute a saved query by ID and display results\n" +
17+
" run-sql - Execute raw DuneSQL inline without saving a query",
1318
}
1419
cmd.AddCommand(newCreateCmd())
1520
cmd.AddCommand(newGetCmd())

cmd/query/run.go

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,31 @@ import (
1313
func newRunCmd() *cobra.Command {
1414
cmd := &cobra.Command{
1515
Use: "run <query-id>",
16-
Short: "Execute a saved query and display results",
17-
Long: "Execute a saved DuneSQL query by its numeric ID and display results.\n\n" +
18-
"By default, polls every 5 seconds for up to ~5 minutes waiting for completion.\n" +
19-
"Use --no-wait to submit the execution and exit immediately; then fetch\n" +
20-
"results later with 'dune execution results <execution-id>'.\n\n" +
16+
Short: "Execute a saved Dune query by its ID and display results",
17+
Long: "Execute a saved Dune query by its numeric ID. By default, waits for the\n" +
18+
"execution to complete (polling every 2 seconds) and displays the result rows.\n" +
19+
"Use --no-wait to submit the execution and exit immediately with just the\n" +
20+
"execution ID; then fetch results later with 'dune execution results <execution-id>'.\n\n" +
21+
"Credits are consumed based on actual compute resources used. Use --performance\n" +
22+
"to select the engine size (medium or large).\n\n" +
23+
"Important: if the query targets tables with known partition columns (returned by\n" +
24+
"'dune dataset search' or 'dune dataset search-by-contract'), ensure the SQL includes\n" +
25+
"a WHERE filter on those partition columns (e.g. WHERE block_date >= CURRENT_DATE -\n" +
26+
"INTERVAL '7' DAY). This enables partition pruning and significantly reduces query cost.\n\n" +
2127
"Examples:\n" +
2228
" dune query run 12345\n" +
2329
" dune query run 12345 --param wallet=0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045 --param days=30\n" +
2430
" dune query run 12345 --performance large --limit 100\n" +
25-
" dune query run 12345 --no-wait",
31+
" dune query run 12345 --no-wait\n" +
32+
" dune query run 12345 --timeout 600",
2633
Args: cobra.ExactArgs(1),
2734
RunE: runRun,
2835
}
2936

30-
cmd.Flags().StringArray("param", nil, "query parameter in key=value format (repeatable)")
31-
cmd.Flags().String("performance", "medium", `performance tier: "medium" (default) or "large" for higher compute resources`)
32-
cmd.Flags().Int("limit", 0, "maximum number of rows to display (0 = all)")
33-
cmd.Flags().Bool("no-wait", false, "submit execution and exit without waiting for results")
37+
cmd.Flags().StringArray("param", nil, "typed query parameter in key=value format (repeatable); supported types: text, number (stringified, e.g. '30'), datetime (YYYY-MM-DD HH:mm:ss), enum")
38+
cmd.Flags().String("performance", "medium", `engine size for the execution: "medium" (default) or "large"; credits are consumed based on actual compute resources used`)
39+
cmd.Flags().Int("limit", 0, "maximum number of result rows to return (0 = all available rows)")
40+
cmd.Flags().Bool("no-wait", false, "submit the execution and exit immediately, printing only the execution ID and state")
3441
cmd.Flags().Int("timeout", 300, "maximum seconds to wait for the execution to complete before timing out")
3542
output.AddFormatFlag(cmd, "text")
3643

cmd/query/run_sql.go

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,31 @@ import (
1010
func newRunSQLCmd() *cobra.Command {
1111
cmd := &cobra.Command{
1212
Use: "run-sql",
13-
Short: "Execute raw DuneSQL and display results",
14-
Long: "Execute a DuneSQL query directly without creating a saved query.\n" +
15-
"Ideal for ad-hoc exploration and one-off analysis.\n\n" +
16-
"By default, polls every 5 seconds for up to ~5 minutes waiting for completion.\n" +
17-
"Use --no-wait to submit and exit immediately.\n\n" +
13+
Short: "Execute a raw DuneSQL query inline and display results",
14+
Long: "Execute an inline SQL statement in DuneSQL dialect without saving it as a\n" +
15+
"query on Dune. Ideal for ad-hoc exploration and one-off analysis.\n\n" +
16+
"By default, waits for completion (polling every 2 seconds) and displays result rows.\n" +
17+
"Use --no-wait to submit the execution and exit immediately with just the\n" +
18+
"execution ID. Credits are consumed based on actual compute resources used.\n\n" +
19+
"Important: if the SQL targets tables with known partition columns (returned by\n" +
20+
"'dune dataset search' or 'dune dataset search-by-contract'), include a WHERE filter\n" +
21+
"on those partition columns (e.g. WHERE block_date >= CURRENT_DATE - INTERVAL '7' DAY).\n" +
22+
"This enables partition pruning and significantly reduces query cost.\n\n" +
1823
"Examples:\n" +
1924
" dune query run-sql --sql \"SELECT block_number, block_time FROM ethereum.blocks ORDER BY block_number DESC LIMIT 5\"\n" +
2025
" dune query run-sql --sql \"SELECT * FROM ethereum.transactions WHERE block_number = {{block_num}}\" --param block_num=20000000\n" +
21-
" dune query run-sql --sql \"SELECT COUNT(*) FROM ethereum.transactions\" --performance large",
26+
" dune query run-sql --sql \"SELECT COUNT(*) FROM ethereum.transactions\" --performance large\n" +
27+
" dune query run-sql --sql \"SELECT 1\" --no-wait",
2228
Args: cobra.NoArgs,
2329
RunE: runRunSQL,
2430
}
2531

26-
cmd.Flags().String("sql", "", "DuneSQL query to execute (required)")
32+
cmd.Flags().String("sql", "", "the SQL query text in DuneSQL dialect (required)")
2733
_ = cmd.MarkFlagRequired("sql")
28-
cmd.Flags().StringArray("param", nil, "query parameter in key=value format (repeatable)")
29-
cmd.Flags().String("performance", "medium", `performance tier: "medium" (default) or "large" for higher compute resources`)
30-
cmd.Flags().Int("limit", 0, "maximum number of rows to display (0 = all)")
31-
cmd.Flags().Bool("no-wait", false, "submit execution and exit without waiting for results")
34+
cmd.Flags().StringArray("param", nil, "typed query parameter in key=value format (repeatable); supported types: text, number (stringified, e.g. '30'), datetime (YYYY-MM-DD HH:mm:ss), enum")
35+
cmd.Flags().String("performance", "medium", `engine size for the execution: "medium" (default) or "large"; credits are consumed based on actual compute resources used`)
36+
cmd.Flags().Int("limit", 0, "maximum number of result rows to return (0 = all available rows)")
37+
cmd.Flags().Bool("no-wait", false, "submit the execution and exit immediately, printing only the execution ID and state")
3238
cmd.Flags().Int("timeout", 300, "maximum seconds to wait for the execution to complete before timing out")
3339
output.AddFormatFlag(cmd, "text")
3440

0 commit comments

Comments
 (0)