Align object to view with Python
bpy.ops.mesh.primitive_*() operators need to be run in a proper context (3D View) in order to use align_view.

Either run an operator via Spacebar menu, or use an override:

import bpy

for area in bpy.context.screen.areas:
    if area.type == 'VIEW_3D':
        for region in area.regions:
            if region.type == 'WINDOW':
                ctx = bpy.context.copy()
                ctx['area'] = area
                ctx['region'] = region
                bpy.ops.mesh.primitive_plane_add(ctx, view_align=True)
                break


Note that there seems to be a bug, the plane appears to be in Edit mode, but the UI reports Object Mode, and the face may be missing.