---
name: Environment Instructions
description: View and update the environment instructions (AGENTS.md) for this task's environment. Use this when users want to update agent guidelines, coding conventions, or environment-specific instructions.
argument-hint: view | update
---

# Environment Instructions Skill

This skill allows you to help the user view and update the environment instructions (AGENTS.md) file for the environment this task is running in.

**IMPORTANT**: This skill requires explicit user approval before making any changes. Always explain what changes you're proposing and ask the user to confirm before executing.

## Available Commands

### 1. View Current Instructions (`/environment-instructions view`)

Use this to view the current AGENTS.md content for the environment.

**When to use:**
- The user asks to see the current environment instructions
- You need to understand the existing guidelines before proposing changes
- The user wants to review what's currently documented

**Process:**
1. Fetch the current AGENTS.md content
2. Display it to the user
3. Offer to help with updates if needed

### 2. Update Instructions (`/environment-instructions update`)

Use this to update the AGENTS.md content based on learnings from this task.

**When to use:**
- The user asks to update environment instructions
- Discoveries during this task suggest guidelines need refinement
- New coding conventions or patterns should be documented
- Important context should be preserved for future tasks

**Process:**
1. Fetch the current instructions
2. Discuss proposed changes with the user
3. Only after user approval, submit the update

## How It Works

This skill communicates with the CoderFlow server via the environment management API. The server URL and task credentials are automatically available in the container environment.

### Environment Variables (automatically set):
- `CODERFLOW_SERVER_URL` - The CoderFlow server URL for API calls
- `TASK_ID` - This task's ID (for authentication)

### API Endpoints:
- `GET /api/environment-management/instructions` - Fetch current AGENTS.md content
- `PATCH /api/environment-management/instructions` - Update AGENTS.md content

## Usage Examples

### Viewing Instructions

```
User: "Show me the current environment instructions"

Agent: I'll fetch the current environment instructions for you.

[Executes API call]

Current AGENTS.md content:
---
# Development Guidelines

## Code Style
- Use TypeScript for all new code
- Follow ESLint configuration
...
---

Would you like to update any of these instructions?
```

### Updating Instructions

```
User: "Add a note about our new logging convention"

Agent: I'll help you update the environment instructions. Let me first fetch the current content...

[Fetches current AGENTS.md]

Current content includes guidelines about code style and testing.

I propose adding the following section:

## Logging Conventions
- Use the `logger` module for all logging
- Include structured context with log messages
- Use appropriate log levels: debug, info, warn, error

Would you like me to apply this update? (Please confirm)

User: "Yes, add it"

Agent: [Executes update via API]
Updated successfully! Future tasks in this environment will see the new logging conventions.
```

## Implementation

The skill executes shell commands to interact with the CoderFlow API:

### Fetch Current Instructions
```bash
curl -s "${CODERFLOW_SERVER_URL}/api/environment-management/instructions" \
  -H "X-Task-Id: ${TASK_ID}"
```

**Response:**
```json
{
  "content": "# Development Guidelines\n\n...",
  "environment": "my-environment",
  "path": "AGENTS.md"
}
```

### Update Instructions
```bash
curl -s -X PATCH "${CODERFLOW_SERVER_URL}/api/environment-management/instructions" \
  -H "Content-Type: application/json" \
  -H "X-Task-Id: ${TASK_ID}" \
  -d '{
    "content": "# Updated Development Guidelines\n\n..."
  }'
```

**Response:**
```json
{
  "success": true,
  "environment": "my-environment",
  "path": "AGENTS.md",
  "updatedAt": "2024-01-15T10:30:00Z",
  "updatedByTaskId": "task-xxx",
  "updatedByUserId": "user-yyy"
}
```

## Important Notes

1. **User Approval Required**: Never execute updates without explicit user confirmation
2. **Explain Changes**: Always clearly explain what changes will be made before asking for approval
3. **Preserve Context**: When updating, preserve any existing context that's still relevant
4. **Be Specific**: Updates should be clear, actionable guidelines
5. **Consider Impact**: Remember that changes affect all future tasks in this environment
6. **Error Handling**: If an API call fails, explain the error to the user and suggest alternatives
