New to Claude Skills? Learn how to install them →

aws on GitHub

Query Data Lake

OfficialFree

Efficiently execute SQL queries on Amazon Athena.

by aws2.3k stars on aws/agent-toolkit-for-aws
5 views
Updated Aug 10, 2026
Get this skill

Free · Opens the source repo

What Query Data Lake does

The Query Data Lake skill facilitates the execution and management of SQL queries on Amazon Athena, covering both default and federated catalogs, including Glue, S3 Tables, and Redshift. This skill is designed for data analysts and developers who need to interact with large datasets stored in AWS, allowing them to execute queries, analyze tables, and obtain insights without the need for extensive manual setup. By leveraging the AWS MCP server for sandboxed execution, users can ensure that their queries are tracked for cost and data scanned, enhancing accountability and cost awareness.

When using this skill, users can easily select the appropriate workgroup and resolve target assets, which helps streamline the querying process. The skill supports a range of SQL statements, categorizing them for safety before execution. For example, it distinguishes between safe and destructive operations, prompting users for confirmation on potentially harmful actions. This level of caution is particularly beneficial for those who may be new to SQL or those working with sensitive data.

Additionally, the skill incorporates features such as schema discovery and profiling of tables before executing analytical queries, which helps users understand the data structure and optimize their queries. It also provides detailed feedback on query execution, including costs and data scanned, which is critical for managing resources effectively in cloud environments. Overall, this skill is a valuable tool for anyone looking to efficiently query and analyze data within the AWS ecosystem.

When to use it

Use this skill when you need to run SQL queries on data stored in AWS Athena, especially when working with large datasets across different catalogs.

When not to use it

This skill is not suitable for finding specific data assets or conducting full catalog audits; those tasks should be handled by other specialized skills.

What you can build with it

Running Analytical Queries

Use this skill to execute complex analytical queries on large datasets stored in AWS, ensuring you understand the schema before execution.

Managing Workgroups

Easily select and manage workgroups for your queries, reducing the risk of errors related to output locations.

Cost Tracking for Queries

Leverage the skill's ability to report costs and data scanned to maintain budget awareness while querying data.

How to install Query Data Lake

View source

1. Install with the skills CLI

npx skills add aws/agent-toolkit-for-aws/querying-data-lake --agent claude-code

2. Or install it manually

Download the skill folder and drop it into ~/.claude/skills/ for all projects, or .claude/skills/ to scope it to one repo. Restart Claude Code so it picks up the new skill.

Anthropic's agentic coding CLI, and the reference implementation of Agent Skills. Drop a skill folder into ~/.claude/skills and Claude Code loads it automatically whenever a task matches the skill's description. Claude Code docs

Inside SKILL.md

Written by aws

Query Data Lake

Execute SQL queries on Amazon Athena across default and federated catalogs (Glue, S3 Tables, Redshift) with workgroup selection, statement classification, and error recovery.

Overview

Executes and manages Athena SQL queries across default and federated catalogs. Selects a workgroup, resolves target assets (delegating fuzzy references to finding-data-lake-assets), classifies statements for safety, and reports cost and data scanned. Use the AWS MCP server for sandboxed execution and audit logging; the same AWS CLI commands work directly when the MCP server is not available.

Constraints for parameter acquisition:

  • You MUST accept a single optional argument: SQL text, a named-query name, a workgroup name, a catalog name, or profile TABLE_NAME
  • You MUST accept the argument as direct text or a pointer to a file containing SQL
  • You MUST ask the user for the target AWS region if not already set
  • You MUST confirm the output S3 location before executing any non-trivial query
  • You MUST respect the user's decision to abort at any step

Common Tasks

1. Verify Dependencies

Check for required tools and AWS access before running queries.

Constraints:

  • You MUST verify AWS MCP server tools are available (aws___call_aws) and run queries through them when present; fall back to AWS CLI only if the MCP server is unavailable
  • You MUST NOT fall back to shell or Bash for query execution — results must be captured via the MCP tool or aws athena CLI so output location and cost are tracked
  • You MUST confirm credentials with aws sts get-caller-identity and inform the user about any missing tools

2. Resolve Workgroup

Check caller identity, list workgroups, auto-select the best one (see workgroup-selection.md).

Constraints:

  • You MUST select a workgroup before submitting any query (prevents output-location errors)
  • You MUST present the selected workgroup and its output location to the user
  • You MUST NOT auto-escalate to a different workgroup on failure without user confirmation

3. Resolve the Target Asset

If the user refers to a table by name, by business concept ("our quarterly report", "the sales data"), by S3 path, or by catalog without specifying the table, delegate to finding-data-lake-assets to return the concrete database.table (and catalog if non-default).

Constraints:

  • You MUST NOT attempt to resolve fuzzy asset references with athena list-data-catalogs or by iterating get-tables — those miss federated catalogs and waste tokens
  • You SHOULD skip this step only when the user provides a fully-qualified reference (exact database.table) or raw SQL they want executed as-is
  • You MUST state the resolved asset explicitly before building the query: "Found [table] in [catalog]. Using this for the query."
  • You SHOULD default to the default Glue catalog unless the user mentions "federated", "Redshift", "S3 Tables", or finding-data-lake-assets returns a different catalog

4. Discover Schema

For analytical queries, You SHOULD profile the target table before building the final query. You MUST show sample rows (SELECT ... LIMIT 5) as part of profiling.

5. Build Query

Table addressing depends on catalog type:

  • Default Glue catalog: database.table (omit the catalog prefix for single-catalog queries). In cross-catalog queries, qualify default-catalog tables with "awsdatacatalog".database.table.
  • Registered data source: datasource.database.table
  • Unregistered Glue catalog: "catalog/subcatalog".database.table

6. Classify and Execute

Classify the SQL statement before executing:

StatementBehavior
SELECT, SHOW, DESCRIBE, EXPLAINSafe — execute
INSERT, UPDATE, DELETE, DROP, ALTER, CREATE, TRUNCATE, MERGEDestructive — warn the user and require explicit confirmation
UnsureTreat as destructive; confirm

Example tool call (via AWS MCP server):

aws___call_aws(command="aws athena start-query-execution --work-group <WORKGROUP_NAME> --query-string '<sql>' --query-execution-context Database=<db>")

For federated or S3 Tables catalogs, also set Catalog=<CATALOG_PATH> in the execution context (e.g. Catalog=s3tablescatalog/<BUCKET_NAME>).

Constraints:

  • You MUST warn the user before executing when the target is Redshift-federated ("No partition pruning — every query scans the full table")
  • You MUST warn the user before executing a cross-catalog join ("Cross-catalog joins incur network overhead and may be slow")
  • You MUST confirm the output S3 location before executing
  • You MUST explain which tool is being called before executing
  • You MUST respect the user's decision to abort

7. Present and Recover

Present results with cost, data scanned, duration, and actionable insights. On failure, list available workgroups and let the user choose which to retry with.

Argument Routing

Resolve in this order; stop at the first match:

  1. Contains SQL keywords (SELECT, SHOW, DESCRIBE, INSERT, etc.) — SQL text, execute directly
  2. profile TABLE_NAME — run comprehensive table profiling (see query-patterns.md)
  3. Matches a known named query — look up and execute
  4. Matches a known workgroup — show workgroup status and recent queries
  5. Matches a known catalog — delegate to exploring-data-catalog to enumerate databases and tables
  6. No args — show recent query activity and available tables

Principles

  • Always select workgroup before executing (prevents output-location errors)
  • Profile unfamiliar tables before running analytical queries
  • Present cost alongside results so users build cost awareness
  • Suggest LIMIT for exploratory queries on large tables
  • Never ask domain questions with obvious answers, but always confirm security-relevant actions (workgroup switches, output location changes, non-SELECT statements)

Troubleshooting

ErrorCauseFix
Redshift identifier error with mixed caseRedshift-federated names are lowercase onlyLowercase the identifier
CatalogId validation failureARN passed instead of catalog namePass the catalog name, not the ARN
Cross-catalog information_schema returns nothingMissing catalog qualifierUse catalog-qualified path: "catalog".information_schema.tables
Query fails with output-location errorWorkgroup has no output location configuredSelect a different workgroup with an output location, or configure one
Destructive statement executed without confirmationStatement classification skippedAlways classify INSERT/UPDATE/DELETE/DROP/ALTER/CREATE/TRUNCATE/MERGE and confirm with the user

Additional Resources

Frequently asked questions about Query Data Lake

Similar skills