I can't seem to find information in the Monster Manual for how to design an opponent with class levels of an appropriate challenge for my 7th-level party. Perhaps this appears in the DMG? I want to make a human assassin entirely using class levels, rather than using the premade assassin in the back of the book. What is the CR/XP vs. character level relationship for creating opponents in 5e?
In the DMG, the "Creating Encounters" section in Chapter 3: Creating Adventures has the XP Thresholds by Character Level table and a procedure for Evaluating Encounter Difficulty, including a sidebar on how CR fits into it.
The DMG also has rules for determining the CR of monsters you create, including class-leveled NPCs, in Chapter 9: Dungeon Master's Workshop, the "Creating a Monster" section. Note that you shouldn't assume that a character of a given level has a certain CR. Instead, the DMG says
[...] determine the NPC’s challenge rating just as you would for a monster.
A little before the DMG's version of the CR to XP chart, there's another chart showing expected proficiency bonus, hit points, AC, damage per round, and etc. There are a series of instructions for how to use this chart (as well as a Monster Features list); that's all quite too long to list here, but as a final note:
Creating a monster isn’t just a number-crunching exercise. The guidelines in this chapter can help you create monsters, but the only way to know whether a monster is fun is to playtest it. After seeing your monster in action, you might want to adjust the challenge rating up or down based on your experiences.
Another good bet is to look at existing examples and eyeball equivalents, but if you want to geek out about it a little more, see for example this detailed blog series analyzing monsters in D&D Next playtest materials and continuing through official 5e.
I've come up with a tangled bit of logic that might at least put you within a reasonable range. Please note that I've never actually played an encounter calculated this way, so I have absolutely no idea how it would work in the wild.
- A Deadly encounter has a "substantial chance of character death"
- A character fighting an exact duplicate of itself would have a 50-50 chance of surviving
- A character is at least a Deadly encounter for itself or, by extension, for a character of equivalent power
So, by this logic, a level 7 NPC would be roughly equivalent to a Deadly encounter for a single level 7 character (i.e. about 1,700 XP).
There are some major caveats here:
- An encounter with a 50% chance of death is probably harder than Deadly, so this approach might make an excessively dangerous encounter
- The encounter might be harder still if the party is arriving at it with depleted resources (reduced HP, expended spell slots/abilities)
- The encounter difficulty table probably incorporates some item acquisition, so the NPC would need appropriate equipment to really be the equivalent of an equal-level PC (this might be a way to reduce the deadliness somewhat)
- The PC classes seem calibrated to function in a party, so even a high-level solo NPC might not perform optimally by itself (Rogues really benefit from someone to duck behind with Cunning Action and to allow them to sneak attack without having advantage)
As nerdy as this sounds, you might want to play out the encounter by yourself a couple of times to get a feel for how the dynamics would play out. My feeling from the Assassin Rogue's abilities is that the combat would be short and one-sided, for one side or the other. Hopefully this still gives you a starting point...
At first level a PC is probably CR 1/2 - 4 of them would be a Deadly encounter for a group of first level PC's.
Unfortunately, this seems to vary a little from level to level.
On average I would assume that an NPC generated in the same manner of a PC would have a CR of 2 below it's class level.
Using the same logic, a group of 4 level 20 PC's could face 4 CR 15 Monsters as a deadly encounter.
You may notice that the Humanoid NPC's in the Monster Manual aren't quite the same as the PC's. The archmage for example is an 18th level wizard in terms of casting level, but lacks many of the special feature that a PC would have at that level. He has a CR of 12. PC's also have other advantages; Permanent Magic Items, One shot items, Preprepared team tactics, potentially dozens of practice battles.
This is just as well, as the GM has so many more things to juggle, they probably won't "benefit" from a running a group of characters of a level of complexity equal to the player characters.
So in conclusion: the formula for adding class levels would not be straightforward, thankfully you have already mentioned the level of your party. For a creature of CR 4+, I would add 1 to the CR for each 3 class levels you add, but strip out some of the complexity.