Verify if credentials and context are actually injected into agent prompts in Autocoder-2.0.

1. cd to C:/Users/MikeSwanson/claude-projects/Autocode-remix/Autocoder-2.0
2. Search for where CredentialResolver is used:
   - grep -rn "CredentialResolver" --include="*.py"
   - grep -rn "credential" --include="*.py" | head -30
3. Check how prompts are built:
   - Read prompts.py - look for where context/credentials might be injected
   - grep -n "credentials" prompts.py
   - grep -n "context" prompts.py
4. Check the agent.py and client.py for context injection
5. Check if there's a CLAUDE.md or context injection in the prompt templates:
   - ls .claude/templates/
   - grep -l "credentials" .claude/templates/*

Report:
- Is CredentialResolver actually used anywhere (not just defined)?
- Are credentials injected into prompts?
- Is server infrastructure context (hosts, IPs) injected?
- What context IS currently injected into agent prompts?


I'll search for credential and context injection in the Autocoder-2.0 codebase.


Bash

cd "C:/Users/MikeSwanson/claude-projects/Autocode-remix/Autocoder-2.0" && grep -rn "CredentialResolver" --include="*.py" 2>/dev/null || echo "No matches found"

Search for CredentialResolver usage in Python files


cd "C:/Users/MikeSwanson/claude-projects/Autocode-remix/Autocoder-2.0" && grep -rn "credential" --include="*.py" 2>/dev/null | head -30

Search for credential mentions in Python files


cd "C:/Users/MikeSwanson/claude-projects/Autocode-remix/Autocoder-2.0" && ls -la .claude/templates/ 2>/dev/null || echo "Directory not found"

List template files in .claude/templates


autonomous_agent_demo.py:65:  Uses Claude CLI credentials from ~/.claude/.credentials.json
autonomous_agent_demo.py:106:    # The Claude SDK auto-detects credentials from ~/.claude/.credentials.json
client.py:95:    The Claude SDK auto-detects credentials from ~/.claude/.credentials.json
config.py:50:    credentials_path: str = "~/claude-projects/shared-data/credentials.md"
prompts.py:22:    from server.services.credential_resolver import CredentialResolver
prompts.py:248:    include_credentials: bool = True,
prompts.py:253:    Includes available servers, services, and credential references from
prompts.py:259:        include_credentials: Whether to include credential reference info
prompts.py:267:        from server.services.credential_resolver import get_resolver
prompts.py:315:    if include_credentials:
prompts.py:318:        lines.append("Credentials are stored in `credentials.md` and can be resolved at runtime.")
prompts.py:319:        lines.append("Use the credential resolver to get secrets when needed:")
prompts.py:323:        lines.append('from server.services.credential_resolver import get_resolver')
prompts.py:328:        lines.append("Or via bash with the credential reference format:")
prompts.py:431:    include_credentials: bool = True,
prompts.py:435:    Inject context (infrastructure, credentials, references) into a prompt.
prompts.py:441:    - `{INFRASTRUCTURE_CONTEXT}` - servers, services, credentials
prompts.py:449:        include_credentials: Whether to include credential references
prompts.py:461:            include_credentials=include_credentials,
server/main.py:66:    allow_credentials=True,
server/main.py:129:    # Check for credentials file
server/main.py:130:    credentials_path = Path.home() / ".claude" / ".credentials.json"
server/main.py:131:    credentials = credentials_path.exists()
server/main.py:139:        credentials=credentials,
server/routers/filesystem.py:97:    r".*credentials.*",  # Credential files
server/routers/terminal.py:171:    credential_ref: Optional[str] = None
server/routers/terminal.py:197:    # Determine auth type based on credential_ref
server/routers/terminal.py:199:    if request.credential_ref:
server/routers/terminal.py:202:            auth = ResourceAuth(type=AuthType.SSH_PASSWORD, credential_ref=request.credential_ref)
server/routers/terminal.py:204:            auth = ResourceAuth(type=AuthType.API_TOKEN, credential_ref=request.credential_ref)


prompts.py:13:- Credential context from CredentialResolver (with redacted secrets)
prompts.py:22:    from server.services.credential_resolver import CredentialResolver
prompts.py:254:    the ResourceManager and CredentialResolver.
server/services/credential_resolver.py:14:class CredentialResolver:
server/services/credential_resolver.py:399:_resolver: CredentialResolver | None = None
server/services/credential_resolver.py:402:def get_resolver(credentials_path: str | None = None) -> CredentialResolver:
server/services/credential_resolver.py:406:        _resolver = CredentialResolver(credentials_path)
server/services/resource_manager.py:18:from .credential_resolver import get_resolver, CredentialResolver
server/services/__init__.py:9:from .credential_resolver import CredentialResolver, get_resolver
server/services/__init__.py:40:    "CredentialResolver",


total 64
drwxr-xr-x 1 AzureAD+MikeSwanson 4096     0 Jan 10 13:25 ./
drwxr-xr-x 1 AzureAD+MikeSwanson 4096     0 Jan 10 13:25 ../
-rw-r--r-- 1 AzureAD+MikeSwanson 4096  9035 Jan  8 08:02 app_spec.template.txt
-rw-r--r-- 1 AzureAD+MikeSwanson 4096 14174 Jan  8 08:02 coding_prompt.template.md
-rw-r--r-- 1 AzureAD+MikeSwanson 4096  7910 Jan  8 08:02 coding_prompt_yolo.template.md
-rw-r--r-- 1 AzureAD+MikeSwanson 4096 19456 Jan  8 08:02 initializer_prompt.template.md


Now let me check the prompts.py file to see how context injection works, and also check the templates and agent.py.


cd "C:/Users/MikeSwanson/claude-projects/Autocode-remix/Autocoder-2.0" && grep -n "credentials\|context\|inject" prompts.py | head -50

Search for credentials, context, inject in prompts.py


cd "C:/Users/MikeSwanson/claude-projects/Autocode-remix/Autocoder-2.0" && grep -n "credentials\|context\|inject\|INFRASTRUCTURE" agent.py 2>/dev/null | head -30

Search for context injection in agent.py


cd "C:/Users/MikeSwanson/claude-projects/Autocode-remix/Autocoder-2.0" && grep -rn "inject_context\|INFRASTRUCTURE_CONTEXT\|build_infrastructure_context" --include="*.py" 2>/dev/null

Search for inject_context and infrastructure context functions


11:Context injection:
12:- Infrastructure context from ResourceManager (servers, services)
13:- Credential context from CredentialResolver (with redacted secrets)
245:def get_infrastructure_context(
248:    include_credentials: bool = True,
251:    Generate infrastructure context for agent prompts.
259:        include_credentials: Whether to include credential reference info
262:        Formatted markdown string with infrastructure context
270:        return _get_fallback_infrastructure_context()
315:    if include_credentials:
318:        lines.append("Credentials are stored in `credentials.md` and can be resolved at runtime.")
338:def _get_fallback_infrastructure_context() -> str:
340:    Fallback infrastructure context when server module isn't available.
367:_Infrastructure context not available. Configure resources using the Terminal._
371:def get_reference_folders_context(project_name: str) -> str:
373:    Generate reference folders context for agent prompts.
426:def inject_context_into_prompt(
431:    include_credentials: bool = True,
435:    Inject context (infrastructure, credentials, references) into a prompt.
437:    Looks for placeholders in the prompt and replaces them with generated context.
438:    If no placeholders exist, appends the context at the end.
441:    - `{INFRASTRUCTURE_CONTEXT}` - servers, services, credentials
448:        include_infrastructure: Whether to include infrastructure context
449:        include_credentials: Whether to include credential references
450:        include_references: Whether to include reference folder context
453:        The prompt with context injected
455:    contexts = []
458:        infra_context = get_infrastructure_context(
461:            include_credentials=include_credentials,
466:            prompt = prompt.replace("{INFRASTRUCTURE_CONTEXT}", infra_context)
468:            contexts.append(infra_context)
471:        ref_context = get_reference_folders_context(project_name)
475:            prompt = prompt.replace("{REFERENCE_CONTEXT}", ref_context)
476:        elif ref_context:
477:            contexts.append(ref_context)
479:    # Append any remaining contexts
480:    if contexts:
481:        prompt = f"{prompt}\n\n---\n\n" + "\n\n".join(contexts)
486:def get_initializer_prompt_with_context(
492:    Load the initializer prompt with infrastructure context injected.
497:        include_infrastructure: Whether to include infrastructure context
500:        The prompt with context
503:    return inject_context_into_prompt(
511:def get_coding_prompt_with_context(
519:    Load the coding prompt with infrastructure and reference context injected.
524:        include_infrastructure: Whether to include infrastructure context
525:        include_references: Whether to include reference folder context
529:        The prompt with context
536:    return inject_context_into_prompt(


177:        # Create client (fresh context)
192:        # Run session with async context manager


prompts.py:426:def inject_context_into_prompt(
prompts.py:441:    - `{INFRASTRUCTURE_CONTEXT}` - servers, services, credentials
prompts.py:465:        if "{INFRASTRUCTURE_CONTEXT}" in prompt:
prompts.py:466:            prompt = prompt.replace("{INFRASTRUCTURE_CONTEXT}", infra_context)
prompts.py:503:    return inject_context_into_prompt(
prompts.py:536:    return inject_context_into_prompt(
venv/Lib/site-packages/mcp/server/fastmcp/prompts/base.py:12:from mcp.server.fastmcp.utilities.context_injection import find_context_parameter, inject_context
venv/Lib/site-packages/mcp/server/fastmcp/prompts/base.py:153:            call_args = inject_context(self.fn, arguments or {}, context, self.context_kwarg)
venv/Lib/site-packages/mcp/server/fastmcp/resources/templates.py:13:from mcp.server.fastmcp.utilities.context_injection import find_context_parameter, inject_context
venv/Lib/site-packages/mcp/server/fastmcp/resources/templates.py:100:            params = inject_context(self.fn, params, context, self.context_kwarg)
venv/Lib/site-packages/mcp/server/fastmcp/utilities/context_injection.py:49:def inject_context(


Let me check where these context injection functions are actually called from (not just defined).


cd "C:/Users/MikeSwanson/claude-projects/Autocode-remix/Autocoder-2.0" && grep -rn "get_infrastructure_context\|get_coding_prompt_with_context\|get_initializer_prompt_with_context\|inject_context_into_prompt" --include="*.py" 2>/dev/null | grep -v "^prompts.py\|^venv\|def "

Find where context injection functions are called from


cd "C:/Users/MikeSwanson/claude-projects/Autocode-remix/Autocoder-2.0" && grep -rn "from prompts import\|from prompts\|import prompts" --include="*.py" 2>/dev/null | grep -v venv

Find files that import from prompts module


cd "C:/Users/MikeSwanson/claude-projects/Autocode-remix/Autocoder-2.0" && grep -l "credentials" .claude/templates/* 2>/dev/null || echo "No credentials mentions in templates"

Check templates for credentials mentions


agent.py:24:from prompts import (
parallel_agent.py:28:from prompts import get_coding_prompt, get_coding_prompt_yolo, copy_spec_to_project, get_initializer_prompt
server/routers/projects.py:50:    from prompts import get_project_prompts_dir, scaffold_project_prompts
start.py:16:from prompts import (


.claude/templates/coding_prompt.template.md
.claude/templates/coding_prompt_yolo.template.md


Let me check what prompts functions are imported in agent.py and start.py, and examine the template files for placeholders.


cd "C:/Users/MikeSwanson/claude-projects/Autocode-remix/Autocoder-2.0" && grep -A5 "from prompts import" agent.py 2>/dev/null

Check what's imported from prompts in agent.py


cd "C:/Users/MikeSwanson/claude-projects/Autocode-remix/Autocoder-2.0" && grep -A5 "from prompts import" start.py 2>/dev/null

Check what's imported from prompts in start.py


cd "C:/Users/MikeSwanson/claude-projects/Autocode-remix/Autocoder-2.0" && grep "INFRASTRUCTURE_CONTEXT\|REFERENCE_CONTEXT\|credentials" .claude/templates/*.md 2>/dev/null

Check templates for context placeholders


from prompts import (
    copy_spec_to_project,
    get_coding_prompt,
    get_coding_prompt_yolo,
    get_initializer_prompt,
)


from prompts import (
    get_project_prompts_dir,
    has_project_prompts,
    scaffold_project_prompts,
)
from registry import (


.claude/templates/coding_prompt.template.md:- **External API not configured**: Third-party service credentials missing (e.g., Stripe keys, OAuth secrets)
.claude/templates/coding_prompt_yolo.template.md:- **External API not configured**: Third-party service credentials missing (e.g., Stripe keys, OAuth secrets)


Interesting - the templates mention "credentials" only in the context of error handling, not as placeholders. Let me check if `get_coding_prompt` or `get_initializer_prompt` call the context injection functions.


cd "C:/Users/MikeSwanson/claude-projects/Autocode-remix/Autocoder-2.0" && grep -n "def get_coding_prompt\|def get_initializer_prompt" prompts.py

Find the definitions of get_coding_prompt and get_initializer_prompt


cd "C:/Users/MikeSwanson/claude-projects/Autocode-remix/Autocoder-2.0" && sed -n '100,180p' prompts.py 2>/dev/null

Read get_coding_prompt and get_initializer_prompt definitions


76:def get_initializer_prompt(project_dir: Path | None = None) -> str:
81:def get_coding_prompt(project_dir: Path | None = None) -> str:
86:def get_coding_prompt_yolo(project_dir: Path | None = None) -> str:
486:def get_initializer_prompt_with_context(
511:def get_coding_prompt_with_context(


        project_dir: The project directory

    Returns:
        The app spec content

    Raises:
        FileNotFoundError: If no app_spec.txt found
    """
    # Try project prompts directory first
    project_prompts = get_project_prompts_dir(project_dir)
    spec_path = project_prompts / "app_spec.txt"
    if spec_path.exists():
        try:
            return spec_path.read_text(encoding="utf-8")
        except (OSError, PermissionError) as e:
            raise FileNotFoundError(f"Could not read {spec_path}: {e}") from e

    # Fallback to legacy location in project root
    legacy_spec = project_dir / "app_spec.txt"
    if legacy_spec.exists():
        try:
            return legacy_spec.read_text(encoding="utf-8")
        except (OSError, PermissionError) as e:
            raise FileNotFoundError(f"Could not read {legacy_spec}: {e}") from e

    raise FileNotFoundError(f"No app_spec.txt found for project: {project_dir}")

def scaffold_project_prompts(project_dir: Path) -> Path:
    """
    Create the project prompts directory and copy base templates.

    This sets up a new project with template files that can be customized.

    Args:
        project_dir: The absolute path to the project directory

    Returns:
        The path to the project prompts directory
    """
    project_prompts = get_project_prompts_dir(project_dir)
    project_prompts.mkdir(parents=True, exist_ok=True)

    # Define template mappings: (source_template, destination_name)
    templates = [
        ("app_spec.template.txt", "app_spec.txt"),
        ("coding_prompt.template.md", "coding_prompt.md"),
        ("coding_prompt_yolo.template.md", "coding_prompt_yolo.md"),
        ("initializer_prompt.template.md", "initializer_prompt.md"),
    ]

    copied_files = []
    for template_name, dest_name in templates:
        template_path = TEMPLATES_DIR / template_name
        dest_path = project_prompts / dest_name

        # Only copy if template exists and destination doesn't
        if template_path.exists() and not dest_path.exists():
            try:
                shutil.copy(template_path, dest_path)
                copied_files.append(dest_name)
            except (OSError, PermissionError) as e:
                print(f"  Warning: Could not copy {dest_name}: {e}")

    if copied_files:
        print(f"  Created prompt files: {', '.join(copied_files)}")

    return project_prompts

def has_project_prompts(project_dir: Path) -> bool:
    """
    Check if a project has valid prompts set up.

    A project has valid prompts if:
    1. The prompts directory exists, AND
    2. app_spec.txt exists within it, AND
    3. app_spec.txt contains the <project_specification> tag

    Args:
        project_dir: The project directory to check


cd "C:/Users/MikeSwanson/claude-projects/Autocode-remix/Autocoder-2.0" && sed -n '76,100p' prompts.py 2>/dev/null

Read the basic get_coding_prompt and get_initializer_prompt functions


def get_initializer_prompt(project_dir: Path | None = None) -> str:
    """Load the initializer prompt (project-specific if available)."""
    return load_prompt("initializer_prompt", project_dir)

def get_coding_prompt(project_dir: Path | None = None) -> str:
    """Load the coding agent prompt (project-specific if available)."""
    return load_prompt("coding_prompt", project_dir)

def get_coding_prompt_yolo(project_dir: Path | None = None) -> str:
    """Load the YOLO mode coding agent prompt (project-specific if available)."""
    return load_prompt("coding_prompt_yolo", project_dir)

def get_app_spec(project_dir: Path) -> str:
    """
    Load the app spec from the project.

    Checks in order:
    1. Project prompts directory: {project_dir}/prompts/app_spec.txt
    2. Project root (legacy): {project_dir}/app_spec.txt

    Args:
        project_dir: The project directory


Now I see the issue. The agent.py imports `get_coding_prompt` and `get_initializer_prompt`, NOT `get_coding_prompt_with_context` or `get_initializer_prompt_with_context`. Let me verify in the agent.py where prompts are actually used.


cd "C:/Users/MikeSwanson/claude-projects/Autocode-remix/Autocoder-2.0" && grep -n "get_coding_prompt\|get_initializer_prompt\|system_prompt\|prompt" agent.py | head -40

Search for prompt usage in agent.py


cd "C:/Users/MikeSwanson/claude-projects/Autocode-remix/Autocoder-2.0" && grep -n "with_context" agent.py 2>/dev/null || echo "No with_context calls in agent.py"

Search for with_context calls in agent.py


24:from prompts import (
26:    get_coding_prompt,
27:    get_coding_prompt_yolo,
28:    get_initializer_prompt,
45:        message: The prompt to send
53:    print("Sending prompt to Claude Agent SDK...\n")
122:        yolo_mode: If True, skip browser testing and use YOLO prompt
180:        # Choose prompt based on session type
181:        # Pass project_dir to enable project-specific prompts
183:            prompt = get_initializer_prompt(project_dir)
186:            # Use YOLO prompt if in YOLO mode
188:                prompt = get_coding_prompt_yolo(project_dir)
190:                prompt = get_coding_prompt(project_dir)
194:            status, response = await run_agent_session(client, prompt, project_dir)


No with_context calls in agent.py


This confirms the issue. Let me also check parallel_agent.py and see what context IS injected into prompts currently.


cd "C:/Users/MikeSwanson/claude-projects/Autocode-remix/Autocoder-2.0" && grep -n "with_context" parallel_agent.py 2>/dev/null || echo "No with_context calls in parallel_agent.py"

Check for with_context calls in parallel_agent.py


cd "C:/Users/MikeSwanson/claude-projects/Autocode-remix/Autocoder-2.0" && grep -rn "get_coding_prompt_with_context\|get_initializer_prompt_with_context" --include="*.py" 2>/dev/null | grep -v "^prompts.py\|venv"

Search for any usage of context-aware prompt functions


cd "C:/Users/MikeSwanson/claude-projects/Autocode-remix/Autocoder-2.0" && head -100 .claude/templates/coding_prompt.template.md 2>/dev/null

Read beginning of coding_prompt template


No with_context calls in parallel_agent.py


## YOUR ROLE - CODING AGENT

You are continuing work on a long-running autonomous development task.
This is a FRESH context window - you have no memory of previous sessions.

### STEP 1: GET YOUR BEARINGS (MANDATORY)

Start by orienting yourself:

```bash
# 1. See your working directory
pwd

# 2. List files to understand project structure
ls -la

# 3. Read the project specification to understand what you're building
cat app_spec.txt

# 4. Read progress notes from previous sessions
cat claude-progress.txt

# 5. Check recent git history
git log --oneline -20
```

Then use MCP tools to check feature status:

```
# 6. Get progress statistics (passing/total counts)
Use the feature_get_stats tool

# 7. Get the next feature to work on
Use the feature_get_next tool
```

Understanding the `app_spec.txt` is critical - it contains the full requirements
for the application you're building.

### STEP 2: START SERVERS (IF NOT RUNNING)

If `init.sh` exists, run it:

```bash
chmod +x init.sh
./init.sh
```

Otherwise, start servers manually and document the process.

### STEP 3: VERIFICATION TEST (CRITICAL!)

**MANDATORY BEFORE NEW WORK:**

The previous session may have introduced bugs. Before implementing anything
new, you MUST run verification tests.

Run 1-2 of the features marked as passing that are most core to the app's functionality to verify they still work.

To get passing features for regression testing:

```
Use the feature_get_for_regression tool (returns up to 3 random passing features)
```

For example, if this were a chat app, you should perform a test that logs into the app, sends a message, and gets a response.

**If you find ANY issues (functional or visual):**

- Mark that feature as "passes": false immediately
- Add issues to a list
- Fix all issues BEFORE moving to new features
- This includes UI bugs like:
  - White-on-white text or poor contrast
  - Random characters displayed
  - Incorrect timestamps
  - Layout issues or overflow
  - Buttons too close together
  - Missing hover states
  - Console errors

### STEP 4: CHOOSE ONE FEATURE TO IMPLEMENT

#### TEST-DRIVEN DEVELOPMENT MINDSET (CRITICAL)

Features are **test cases** that drive development. This is test-driven development:

- **If you can't test a feature because functionality doesn't exist → BUILD IT**
- You are responsible for implementing ALL required functionality
- Never assume another process will build it later
- "Missing functionality" is NOT a blocker - it's your job to create it

**Example:** Feature says "User can filter flashcards by difficulty level"
- WRONG: "Flashcard page doesn't exist yet" → skip feature
- RIGHT: "Flashcard page doesn't exist yet" → build flashcard page → implement filter → test feature

Get the next feature to implement:

```
# Get the highest-priority pending feature


cd "C:/Users/MikeSwanson/claude-projects/Autocode-remix/Autocoder-2.0" && grep "INFRASTRUCTURE\|{.*CONTEXT}" .claude/templates/*.md 2>/dev/null || echo "No INFRASTRUCTURE or CONTEXT placeholders in templates"

Check for infrastructure placeholders in templates


cd "C:/Users/MikeSwanson/claude-projects/Autocode-remix/Autocoder-2.0" && grep -rn "load_prompt" --include="*.py" 2>/dev/null | grep -v venv | head -20

Check what load_prompt does


No INFRASTRUCTURE or CONTEXT placeholders in templates


prompts.py:33:def load_prompt(name: str, project_dir: Path | None = None) -> str:
prompts.py:78:    return load_prompt("initializer_prompt", project_dir)
prompts.py:83:    return load_prompt("coding_prompt", project_dir)
prompts.py:88:    return load_prompt("coding_prompt_yolo", project_dir)


cd "C:/Users/MikeSwanson/claude-projects/Autocode-remix/Autocoder-2.0" && sed -n '33,75p' prompts.py 2>/dev/null

Read load_prompt function


def load_prompt(name: str, project_dir: Path | None = None) -> str:
    """
    Load a prompt template with fallback chain.

    Fallback order:
    1. Project-specific: {project_dir}/prompts/{name}.md
    2. Base template: .claude/templates/{name}.template.md

    Args:
        name: The prompt name (without extension), e.g., "initializer_prompt"
        project_dir: Optional project directory for project-specific prompts

    Returns:
        The prompt content as a string

    Raises:
        FileNotFoundError: If prompt not found in any location
    """
    # 1. Try project-specific first
    if project_dir:
        project_prompts = get_project_prompts_dir(project_dir)
        project_path = project_prompts / f"{name}.md"
        if project_path.exists():
            try:
                return project_path.read_text(encoding="utf-8")
            except (OSError, PermissionError) as e:
                print(f"Warning: Could not read {project_path}: {e}")

    # 2. Try base template
    template_path = TEMPLATES_DIR / f"{name}.template.md"
    if template_path.exists():
        try:
            return template_path.read_text(encoding="utf-8")
        except (OSError, PermissionError) as e:
            print(f"Warning: Could not read {template_path}: {e}")

    raise FileNotFoundError(
        f"Prompt '{name}' not found in:\n"
        f"  - Project: {project_dir / 'prompts' if project_dir else 'N/A'}\n"
        f"  - Templates: {TEMPLATES_DIR}"
    )


Now I have a clear picture. Let me summarize by checking one more thing - whether any caller anywhere actually uses the context-aware functions.


cd "C:/Users/MikeSwanson/claude-projects/Autocode-remix/Autocoder-2.0" && grep -rn "inject_context_into_prompt\|get_infrastructure_context\|_with_context" --include="*.py" 2>/dev/null | grep -v "^prompts.py\|^venv\|def " | head -20

Final check for any usage of context injection


No output means no callers. Let me also check the server API routes to see if context might be injected there.


cd "C:/Users/MikeSwanson/claude-projects/Autocode-remix/Autocoder-2.0" && grep -rn "infrastructure\|credential" server/routers/*.py 2>/dev/null | head -20

Check server routers for infrastructure/credential handling


server/routers/filesystem.py:97:    r".*credentials.*",  # Credential files
server/routers/terminal.py:7:infrastructure configuration.
server/routers/terminal.py:171:    credential_ref: Optional[str] = None
server/routers/terminal.py:197:    # Determine auth type based on credential_ref
server/routers/terminal.py:199:    if request.credential_ref:
server/routers/terminal.py:202:            auth = ResourceAuth(type=AuthType.SSH_PASSWORD, credential_ref=request.credential_ref)
server/routers/terminal.py:204:            auth = ResourceAuth(type=AuthType.API_TOKEN, credential_ref=request.credential_ref)


Now I have all the information I need. Here is my report:

---

## Report: Credential and Context Injection in Autocoder-2.0

### Summary

**CredentialResolver is DEFINED but NOT USED in agent prompts.**

### Detailed Findings

#### 1. Is CredentialResolver Actually Used? (Not Just Defined)

**Partially.** The `CredentialResolver` class exists in:
- `C:\Users\MikeSwanson\claude-projects\Autocode-remix\Autocoder-2.0\server\services\credential_resolver.py`

It IS imported/referenced in:
- `prompts.py` (lines 22, 254-328) - but only within functions that are NEVER CALLED
- `server/services/resource_manager.py` - for internal resource management
- `server/routers/terminal.py` - for SSH authentication via `credential_ref`

**The terminal router CAN use credentials for SSH connections**, but this is NOT prompt injection - it's runtime authentication.

#### 2. Are Credentials Injected into Prompts?

**NO.** The `agent.py` file imports and uses:
```python
from prompts import (
    get_coding_prompt,          # <-- Does NOT inject context
    get_coding_prompt_yolo,     # <-- Does NOT inject context
    get_initializer_prompt,     # <-- Does NOT inject context
)
```

There are context-aware versions defined in `prompts.py`:
- `get_initializer_prompt_with_context()` (line 486)
- `get_coding_prompt_with_context()` (line 511)
- `inject_context_into_prompt()` (line 426)

**But these functions are NEVER called anywhere** - they have ZERO callers outside of `prompts.py`.

#### 3. Is Server Infrastructure Context (Hosts, IPs) Injected?

**NO.** The templates in `.claude/templates/` contain:
- NO `{INFRASTRUCTURE_CONTEXT}` placeholders
- NO `{REFERENCE_CONTEXT}` placeholders
- The only "credentials" mention is in error handling documentation

The `inject_context_into_prompt()` function looks for these placeholders:
```python
# From prompts.py line 441
# - `{INFRASTRUCTURE_CONTEXT}` - servers, services, credentials
# - `{REFERENCE_CONTEXT}` - reference folder paths
```

But since templates don't contain these placeholders AND the function is never called, injection never happens.

#### 4. What Context IS Currently Injected into Agent Prompts?

**Only the raw template content:**
1. Project-specific prompt from `{project_dir}/prompts/{name}.md` (if exists)
2. Fallback to base template from `.claude/templates/{name}.template.md`

The prompts focus on:
- General coding agent instructions
- Test-driven development workflow
- Feature management via MCP tools
- Git and bash conventions

**NO infrastructure context, NO credential references, NO server information is injected.**

### The Gap

The code has a complete infrastructure for context injection:
1. `CredentialResolver` - parses credentials.md, redacts secrets
2. `ResourceManager` - knows about servers, services
3. `get_infrastructure_context()` - builds formatted markdown with servers, services, credential instructions
4. `inject_context_into_prompt()` - replaces placeholders or appends context
5. `*_with_context()` - convenience wrappers

**But agent.py never uses any of this.** It uses the basic `get_coding_prompt()` instead of `get_coding_prompt_with_context()`.

### Fix Required

In `agent.py`, change lines 183-190 from:
```python
prompt = get_initializer_prompt(project_dir)
# ...
prompt = get_coding_prompt_yolo(project_dir)
# ...
prompt = get_coding_prompt(project_dir)
```

To:
```python
from prompts import (
    get_initializer_prompt_with_context,
    get_coding_prompt_with_context,
)
# ...
prompt = get_initializer_prompt_with_context(project_dir)
# ...
prompt = get_coding_prompt_with_context(project_dir, yolo=True)
# ...
prompt = get_coding_prompt_with_context(project_dir)
```

And add `{INFRASTRUCTURE_CONTEXT}` placeholder to the templates if you want control over where it appears.