NetHack Agent Skills
This directory contains behavioral skills for the NetHack agent. Skills are Python async functions that interact with the game through the NetHackAPI.
Best use case
NetHack Agent Skills is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
This directory contains behavioral skills for the NetHack agent. Skills are Python async functions that interact with the game through the NetHackAPI.
Teams using NetHack Agent Skills should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/skills/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How NetHack Agent Skills Compares
| Feature / Agent | NetHack Agent Skills | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
This directory contains behavioral skills for the NetHack agent. Skills are Python async functions that interact with the game through the NetHackAPI.
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# NetHack Agent Skills
This directory contains behavioral skills for the NetHack agent. Skills are Python async functions that interact with the game through the NetHackAPI.
## Skill Structure
Every skill must follow this structure:
```python
async def skill_name(nh, **params):
"""
Brief description of what this skill does.
Category: category_name
Stops when: condition1, condition2, condition3
Args:
nh: NetHackAPI instance
param1: Description of param1
param2: Description of param2
Returns:
SkillResult with execution outcome
"""
# Implementation
return SkillResult.stopped(
"stop_reason",
success=True,
actions=actions_taken,
turns=turns_elapsed,
# Additional data...
)
```
### Required Elements
1. **Async function**: All skills are async to allow cooperative execution
2. **First parameter `nh`**: The NetHackAPI instance for game interaction
3. **`**params`**: Accept additional keyword arguments for flexibility
4. **Docstring with metadata**:
- `Category:` - Skill category (exploration, combat, resource, navigation, interaction, utility, custom)
- `Stops when:` - Comma-separated list of stop conditions
5. **Return SkillResult**: Always return via `SkillResult.stopped()` with stop reason
## Categories
### exploration
Skills for exploring the dungeon, finding stairs, discovering rooms.
- `cautious_explore` - Explore until danger is encountered
### combat
Skills for fighting monsters in various situations.
- `melee_fight` - Basic adjacent melee combat
### resource
Skills for managing consumables, food, and healing.
- `eat_when_hungry` - Consume food when hunger threshold reached
### navigation
Skills for pathfinding and movement to specific locations.
- (Agent will generate as needed)
### interaction
Skills for interacting with NPCs, shops, and altars.
- (Agent will generate as needed)
### utility
Skills for misc actions like searching, identifying items.
- (Agent will generate as needed)
### custom
Agent-generated skills that don't fit other categories.
- (Dynamically created)
## Available API Methods
Skills have access to these NetHackAPI methods:
### State Queries
- `nh.get_stats()` - Player stats (HP, power, AC, XP, gold, hunger)
- `nh.get_position()` - Player position
- `nh.get_screen()` - Current 24x80 TTY display
- `nh.get_message()` - Current game message
- `nh.get_visible_monsters()` - All monsters in view
- `nh.get_adjacent_monsters()` - Monsters in 8 adjacent tiles
- `nh.get_inventory()` - Current inventory
- `nh.get_items_here()` - Items at player's position
- `nh.turn` - Current game turn
- `nh.is_done` - Whether game is over
### Movement Actions
- `nh.move(direction)` - Move in direction (returns ActionResult)
- `nh.move_to(position)` - Move toward target position
- `nh.go_up()` - Ascend stairs
- `nh.go_down()` - Descend stairs
### Combat Actions
- `nh.attack(direction)` - Attack in direction
- `nh.kick(direction)` - Kick in direction
### Item Actions
- `nh.pickup()` - Pick up items at feet
- `nh.drop(slot)` - Drop item from inventory slot
- `nh.eat(slot)` - Eat item from inventory
- `nh.quaff(slot)` - Drink potion
- `nh.read(slot)` - Read scroll/spellbook
- `nh.zap(slot, direction)` - Zap wand
- `nh.wear(slot)` - Wear armor
- `nh.wield(slot)` - Wield weapon
- `nh.take_off(slot)` - Remove worn item
### Utility Actions
- `nh.wait()` - Wait one turn
- `nh.search()` - Search for secret doors/traps
- `nh.open_door(direction)` - Open door in direction
- `nh.pray()` - Pray to your god
### Pathfinding
- `nh.find_path(target)` - Find path to target position
- `nh.find_unexplored()` - Find nearest unexplored area
- `nh.find_nearest(predicate)` - Find nearest tile matching condition
### Knowledge
- `nh.is_dangerous_melee(monster_name)` - Check if monster is dangerous in melee
- `nh.is_dangerous_corpse(corpse_name)` - Check if corpse is unsafe to eat
## Stop Conditions
Skills should return with clear stop reasons:
### Common Stop Reasons
- `game_over` - Game ended (death or win)
- `low_hp` - HP below threshold
- `max_steps` / `max_rounds` - Iteration limit reached
- `success` - Primary goal achieved
### Combat-Specific
- `target_dead` - Enemy killed
- `no_target` - No valid target found
- `dangerous_monster` - Encountered a too-dangerous foe
### Exploration-Specific
- `monster_adjacent` - Hostile monster next to player
- `monster_spotted` - Hostile monster visible nearby
- `fully_explored` - Level completely explored
### Resource-Specific
- `ate_food` - Successfully ate
- `no_food` - No food available
- `not_hungry` - Don't need to eat
## Writing New Skills
When the agent generates new skills:
1. **Follow the structure** - Use the template above
2. **Be defensive** - Check game state, handle edge cases
3. **Return early** - Stop when conditions are met
4. **Include data** - Return useful info in SkillResult for analysis
5. **Limit loops** - Always have a max iteration count
### Example: Generated Ranged Combat Skill
```python
async def ranged_attack(nh, max_shots: int = 10, **params):
"""
Attack monsters with ranged weapons or thrown items.
Category: combat
Stops when: out_of_ammo, target_dead, target_out_of_range, low_hp, max_shots
Args:
nh: NetHackAPI instance
max_shots: Maximum projectiles to throw
"""
shots_fired = 0
turns_start = nh.turn
for _ in range(max_shots):
if nh.is_done:
return SkillResult.stopped("game_over", success=False, shots=shots_fired)
stats = nh.get_stats()
if stats.hp / stats.max_hp < 0.2:
return SkillResult.stopped("low_hp", success=False, shots=shots_fired)
# Find ranged weapon or projectiles in inventory
inventory = nh.get_inventory()
projectiles = [i for i in inventory if i.is_projectile]
if not projectiles:
return SkillResult.stopped("out_of_ammo", success=shots_fired > 0, shots=shots_fired)
# Find visible target
visible = nh.get_visible_monsters()
hostile = [m for m in visible if m.is_hostile]
if not hostile:
return SkillResult.stopped("target_dead", success=True, shots=shots_fired)
target = hostile[0]
direction = stats.position.direction_to(target.position)
if direction is None:
return SkillResult.stopped("target_out_of_range", success=False, shots=shots_fired)
# Fire!
nh.throw(projectiles[0].slot, direction)
shots_fired += 1
return SkillResult.stopped(
"max_shots",
success=True,
shots=shots_fired,
turns=nh.turn - turns_start,
)
```
## Security
Skills run in a sandboxed environment with restrictions:
- **No file I/O** - Cannot read/write files
- **No network** - Cannot make network calls
- **No shell** - Cannot execute commands
- **Limited imports** - Only asyncio, typing, math, etc.
- **Time limited** - Skills timeout after configured duration
- **Memory limited** - Container has 256MB RAM limit
The sandbox validates all code before execution to prevent malicious operations.Related Skills
nanobanana-ppt-skills
AI-powered PPT generation with document analysis and styled images
makepad-skills
Makepad UI development skills for Rust apps: setup, patterns, shaders, packaging, and troubleshooting.
claude-scientific-skills
Scientific research and analysis skills
find-skills
Helps users discover and install agent skills when they ask questions like "how do I do X", "find a skill for X", "is there a skill that can...", or express interest in extending capabilities. This skill should be used when the user is looking for functionality that might exist as an installable skill.
ht-skills
管理灏天文库文集和文档,支持新建文集、新建文档、查询文集/文档、更新文档、修改文档归属、管理文档层级。适用于 OpenClaw 自主写文章并上传、文集创建、文档入库、文档移动等场景。
web-skills-protocol
Auto-discover and use Web Skills Protocol (WSP) skills when interacting with websites. Use this skill whenever the user asks you to interact with, use, or perform actions on a website or web service — such as searching a site, placing an order, deploying an app, or calling a web API. Before scraping HTML or guessing at interfaces, check if the site publishes a skills.txt or agents.txt file that teaches you how to use it properly. If a website has complex elements (e.g., heavy JavaScript, interactive UIs), activating this skill can also help you understand the site's purpose and capabilities. Do NOT use for local file operations or non-web tasks.
clawdtm-skills
Review and rate Claude Code skills. See what humans and AI agents recommend.
micropython-skills/sensor
MicroPython sensor reading — DHT11/22, BME280, MPU6050, ADC, ultrasonic HC-SR04, photoresistor, generic I2C sensors.
micropython-skills/network
MicroPython networking — WiFi STA/AP, HTTP requests, MQTT pub/sub, BLE, NTP time sync, WebSocket.
micropython-skills/diagnostic
MicroPython device diagnostics — system info, I2C/SPI bus scan, pin state, filesystem, memory, performance benchmarks.
micropython-skills/algorithm
MicroPython on-device algorithms — PID controller, moving average, Kalman filter, state machine, task scheduler, data logger.
micropython-skills/actuator
MicroPython actuator control — GPIO output, PWM (LED/servo/motor), stepper motor, WS2812 NeoPixel, buzzer.